3 ms·
Unfortunately that web page cannot be fixed via "reader" mode in Safari. But as I read it I felt there was an implicit "yes, but" running through it. To step
by gumby 8y ago
Unfortunately that web page cannot be fixed via "reader" mode in Safari.
But as I read it I felt there was an implicit "yes, but" running through it. To step up a level:
- unexpected problems occur
- you have to manage them.
- managing error return codes is tedious, and consumes a lot of lines of code, which is an opportunity for errors in and of itself.
Try/catch is a sign that something went wrong, but it allows you to manage sequence points (via catch) to deal with them. With unwind-protect (typically via automatic destructors in contemporary languages) most of the required boilerplate is automated. Yes, there are corner cases (e.g. the reason for C++'s make_shared) but there are many more when you're tracking error returns.
Now where I disagree right up front is that try/catch is not a way to "handle errors". It's a way to deal with them. We already have experience of using signalling to handle errors: the Common Lisp condition system allowed you to catch an error and restart the computation. It was a wonderful, general mechanism (even more general than just this case described here) and indeed, it was so general and so powerful that it also turned out to be an opportunity for incomprehensible code. We all learned from that, which is why nobody else has a facility for handling errors.
(BTW another great example of this kind of generality was method combinators. Sounds great but in practice: no thanks!)