As a side note, the author talks about exceptions ...
# thinking-together
a
As a side note, the author talks about exceptions as though they are a Good Thing (TM). I'm not sure if other languages have somehow fixed the issues with them, but I tend to agree with Raymond Chen's analysis here - exceptions are too difficult to handle or recognize when poorly handled: https://blogs.msdn.microsoft.com/oldnewthing/20050114-00/?p=36693/
s
Agreed, exceptions seem wonky to me as well but I'm not sure what'd be better
a
My current preference is to treat errors as just other valid return values/states to be dealt with (assuming they're recoverable)... There may well be better ways. The erlang model of restarting services [terminology?] sounds promising for a large number of scenarios, and the `nursery`/`bundle` approach linked in my previous OP would seem to allow this in even low-level languages... something to experiment with! 🙂
w
Exceptions as such conflate error handling with jumping up the stack. Lisp's condition system is the closest sane alternative I've used http://www.gigamonkeys.com/book/beyond-exception-handling-conditions-and-restarts.html.
Instead of recovering somewhere up the stack, install continuations going down the stack. It's most useful for debugging. With Exceptions, the common practice of breaking when they are thrown should be a red flag that the behavior of walking up the stack shouldn't be the default.
🤔 1
a
Thanks for that @wtaysom. I'm not fluent in LISP, so there was a bit of a language barrier! I've internally translated into C to try to evaluate it. I'm not sure this is quite right, so please correct me where I'm wrong... It seems like an expansion of the fairly common pattern of proving a function pointer to handle errors: Instead of a single handler, you provide/build a list/stack of error 'restarts' and another 'handler' that chooses the appropriate restart to use. This certainly seems like it could a useful technique. It's hard to see a priori where the benefits/drawbacks would be. I'll have to try it out and see!