R
Robbert Haarman
On Thu, Feb 08, 2007 at 03:20:12PM +0000, nukleus wrote:
<insightful comments about using exceptions>
You're right. Exceptions in general, and checked exceptions in
particular, can be very useful and very elegant. I don't think anybody
here doubts that (if so, please post).
However, James's original question was about the trows clause, and the
fact that you have to explicitly list the checked exceptions that a
method throws. In other words, it's not about the utility of exceptions
in general, but about the utility vs. burden of the throws clause.
I particularly dislike the trows clause, and the fact that you have to
add and update throms clauses on all methods that call a certain method,
when these methods are not interested in handling an exceptions
throwable by a "lower" method. However, I am curious what other people,
particularly people who actually _like_ Java, think about the issue.
That's not necessarily true. If I understand correctly, in Java there is
indeed no way to get back to the place an exception was thrown from.
However, it doesn't have to be that way. Common Lisp, for example,
allows the operation that caused the error to be retried (e.g. after
changing some parameters) or to specify a return value to be used
instead of the expression that caused the error, in addition to simply
aborting the operation and transfering control to wherever the exception
handler is.
Regards,
Bob
<insightful comments about using exceptions>
You're right. Exceptions in general, and checked exceptions in
particular, can be very useful and very elegant. I don't think anybody
here doubts that (if so, please post).
However, James's original question was about the trows clause, and the
fact that you have to explicitly list the checked exceptions that a
method throws. In other words, it's not about the utility of exceptions
in general, but about the utility vs. burden of the throws clause.
I particularly dislike the trows clause, and the fact that you have to
add and update throms clauses on all methods that call a certain method,
when these methods are not interested in handling an exceptions
throwable by a "lower" method. However, I am curious what other people,
particularly people who actually _like_ Java, think about the issue.
The extreme case: use the exceptions everywhere,
is simply foolish. First of all, you need to understand
the very nature of exceptions and it is essentially
an equivalent of a goto statement, that totally screws
up your stack and throws your program into place
you could not have imagine.
That's not necessarily true. If I understand correctly, in Java there is
indeed no way to get back to the place an exception was thrown from.
However, it doesn't have to be that way. Common Lisp, for example,
allows the operation that caused the error to be retried (e.g. after
changing some parameters) or to specify a return value to be used
instead of the expression that caused the error, in addition to simply
aborting the operation and transfering control to wherever the exception
handler is.
Regards,
Bob