| Working with and implementing C++ exceptions for 30 years now, including implementing exception handling for Windows, DOS extenders, and Posix (all very different), and then re-implementing them for D, I have sadly come to the conclusion that exceptions are a giant mistake. 1. they are very hard to understand all the way down 2. they are largely undocumented in how they're implemented 3. they are slow when thrown 4. they are slow when not thrown 5. it is hard to write exception-safe code 6. very few understand how to write exception-safe code 7. there is no such thing as zero-cost exception handling 8. optimizers just give up trying to do flow analysis in try-exception blocks 9. consider double-fault exceptions - there's something that shows how rotten it is 10. has anyone yet found a legitimate use for throwing an `int`? I have quit using exceptions in my own code, making everything 'nothrow'. I regret propagating exception handling into D. Constructors that may throw are an abomination. Destructors that throw are even worse. |
[1] I attended a presentation on it by MS soon after Win64 came out. All I could think of at the end was "what's a cubit". I understood exactly nothing about it.