Article:
 |
|
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,
|
Showing messages 1 through 1 of 1.
In general, I'm not a fan of writing code to tell the compiler to do nothing. Sometimes I want to ignore FileNotFound -- it's okay, I know what I'm doing.