4 ms·
Conditions are brilliant. This is something I wish more languages would copy from CL. Having said that, this [1] is a better treatment of conditions, what the
by danssig 15y ago
Conditions are brilliant. This is something I wish more languages would copy from CL. Having said that, this [1] is a better treatment of conditions, what they can do and why you'd want them.
@Total_Meltdown Conditions are just that: conditions. Not necessarily errors or exceptions. Exceptions are a subset of conditions ("exceptional" is a condition). So if X is an error for your application you can unwind the stack if you want to. Or you can try to fix the error in-place without trashing the rest of whatever the program was doing. And yes, conditions allow one to establish protocols between lower and higher levels of code.
The insight of conditions is that the code that detects the error may know ways of dealing with it but only higher level code can know what should actually be done. There are other ways of dealing with this (e.g. passing delegates) but all of them are much more clumsy than this system [2].
[1] http://www.gigamonkeys.com/book/beyond-exception-handling-conditions-and-restarts.html http://www.gigamonkeys.com/book/beyond-exception-handling-co...
[2] Passing delegates was mentioned as a means of passing the condition handling code, but the issue is that the code may be 20 layers down the stack. Is every called method going to pass this delegate? Wont they have some failure conditions themselves?