Re: unhandled exceptions and exception specs
ytrembla@nyx.nyx.net (Yannick Tremblay) wrote in news:1205257098.852729
@irys.nyx.net:
Is it possible for a compiler to catch spot these error?
Would it make sense?
Or in the generic sense: can we make them useful rather than as
H. Sutter concludes:
http://www.gotw.ca/publications/mill22.htm
- Moral #1: Never write an exception specification.
- Moral #2: Except possibly an empty one, but if I were you I'd avoid
even that.
This question has been discussed to death more than a few times already.
In general, you can't break existing code so the point is moot to start
off. Some of the problems are: 1) How do you specify the exceptions
from an interface? 2) Same thing for function pointers. 3) templates?
The second question is should we care? Googling on Java Checked
exceptions indicates that this is a feature that is only useful for
small to toy programs. The bigger the program, the less return on
investment you get by deploying checked exceptions. In fact,
programmers quickly start just throwing Exception so they don't have to
list the dozen possible exceptions they may see that they don't really
care about because they aren't going to handle them anyway. The other
problem is versioning and maintenance. If a new exception is added to
support a new feature, potentially dozens of classes (which don't care
about this exception) will have to be changed to now accept it as one of
their pass-thrus.
No, I would say that checked exceptions were an experiment that failed.
You will notice that no other languages have been clamouring to add
them.
joe