Quote:
|
Originally Posted by DaWei
Quote:
|
Originally Posted by MrSmiley
DaWei, what is your take on c++'s try...catch excetion handeling?
|
I think it's a good mechanism to use for extraordinary errors or in situations where you want some class of errors to be handled from a central location. I would never use it in place of simple status checks.
|
I agree with this 100%. Exceptions are fine when the error is caused by something completely beyond your control, such as hardware failure. However, exceptions are also an order of magnitude more expensive from an efficiency standpoint than a simple compare, and as such, shouldn't be used as a replacement for checking return values.
This is one of my main beefs with Java. The language designers opted to use exceptions for nearly all error conditions; you see things like a method with a void return type throwing an exception, where returning a success/failure code would seem to be much easier. Of course, this isn't a flaw of the language itself, but rather of the design of the standard libraries.