3 ms·
What is bad about exceptions?
by evilsetg 6y ago
What is bad about exceptions?
- brobinson 6y agoThey will be used for flow control in small, individually innocent ways until they've accumulated into the type of hell the OP of this thread is describing.
- phoe-krk 6y agoA solution is to use languages that make explicit control flow available, instead of pretending that exceptions are a good way of performing non-local jumps. Have you investigated Common Lisp, its use of BLOCK/RETURN-FROM and TAGBODY/GO, and how it is possible to close over these lexical constructs to achieve non-local jumps to predefined points on the stack ? All of Common Lisp's error handling system is based on this primitive mechanism (and therefore written in Lisp itself). (Disclosure: wrote a book on the topic.)
- kettro 6y agoExceptions form a secondary, unseen form of control flow. A program can exit via ‘return’ calls (as normal), or at any time by some internal function way down the stack throwing an exception for something that could have been an error code. Exceptions are not Structured Programming: they are worse than goto, because at least goto is scope-local. If, maybe, the language enforced that all throwable exceptions are declared by the prototype, then it’d be alright. But I don’t know of any that do. So, given a function call, will it error out? Can you know without inspecting the source, if you even have it?
- MrBuddyCasino 6y ago> they are worse than goto, because at least goto is scope-local Thanks, you said it better than me. This is the essence.