55 points · by sevko · 11y ago · 27 comments
But that was interesting read non the less, thanks OP.
>> I think exceptions are very bad idea.
There are many cases, API implementations for example, where I cannot think of a better solution. Packing result codes into returned data, using return values, using global state, using passed state buffers, all those approaches are worse, imo, and lead to less readable and maintainable code. What's your preferred alternative?
In Java/C# I have to use what other people are using :)
My dislike of exceptions (as well as errno and Set/GetLastError) is due their masking, hiding error conditions and situations. And I prefer everything to be stated clearly. Including error handling code (answer to 'did I handled all possible failures of calling this?' should be instant).
Unfortunately proper error handling is hard, nearly as much as 'naming things' :)
Actually, being part of the ISO C standard, they are not platform-specific. Otherwise, just use C++ where destructors take care of cleanup when an exception is thrown.
The standard doesn't define the full semantics, specially what happens when a signal, trap, OS exception and similar occurs.
No they really don't; sometimes you have no choice but to use C because you're using a framework or platform where that's the only option.
This is why you had to push all local variables onto a clearnup list in each an every function, this I think, from memory was a call to CleanupStack::Push with a wrapper macro.
If indeed they did this becuase exxceptions were 'too slow', then the problem, im my option would be that they were using exceptions far too much -- as status indications and so on. They are, again, in my option a great help used in the right way, with the C++ RAII idiom, which is essential in the face of exceptions.
I believe the paper of Wadler makes this most clear. Some time ago, it was a real eye-opener for me:
http://homepages.inf.ed.ac.uk/wadler/papers/essence/essence....