Re: [AD] 4.3 error handling |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Thursday 08 June 2006 11:59, Robert Ohannessian wrote:
> So, C "exceptions" using setjmp don't really work like C++ exceptions,
> have lots of gotchas, don't interoperate and (to make them work
> correctly) complicate the user code much more than just checking for
> return values.
They don't have many gotchas. al_try must be followed by al_catch, and don't
prematurely leave a try block (for which a function could be added, or
basically an existing function renamed and publicised). What's so bad? Any
method you put in will have some gotchas, there's no escaping that.
And I'd say it makes user code much simpler. Having to check return values
makes it much harder because you gotta know which ones can error, what the
failure value is, then you gotta specificly branch and copy the error
handling code you have from elsewhere for each function that can fail.
This helps newbies by providing nicer information for uncaught errors (no
more 'why is Windows closing my program and saying "the address can't
be 'read'"?'), it helps users that like it by allowing them to use a familiar
method, and with both of that, it still allows you to use the method of
checking return values, if you wish.
Given that, the question shouldn't be "why use it?", it should be "why not use
it?", IMO. I'm willing to believe there could be a problem with this method,
which is why I brought it up for discussion and have been trying to get many
opiinions on it, but so far, the only real problem cases brought up are
caused by user error.
> Why is this thread still alive?
Because I think it's a good idea and most of the concerns people are putting
up are either rare cases that were sloppily coded, or because they don't feel
comfortable with C having C++ like features, it seems.