What I Hate About Your Programming Language
Subject:   Java + Exceptions
Date:   2003-05-14 09:44:13
From:   anonymous2
Response to: Java + Exceptions

Actually what the author and others are defending is that you can do this:

voif foo() {
// ...

and if an exception is raised, it goes up to where is caught, or thrown to the toplevel.

C++ expections are this way, you don't have to declare which exceptions can foo() trow, and it's actually Bad to do so, except when you want to guarantee the compiler it throws none (example: destructors:

MyClass::~MyClass() throws ()
// destructors *cannot* throw or Really Evil Things will happen

any other exception spec is discouraged, they aren't optimization hints, nor actually document the exceptions that can be thrown by a function: libraries can throw their own exceptions, without limitations...)

best regards,

1 to 1 of 1
  1. Java + Exceptions
    2003-05-14 10:51:38  chromatic | O'Reilly AuthorO'Reilly Blogger [View]

1 to 1 of 1