3 ms·
I thought that exceptions were intended for the one situation where people more or less agreed goto could be a net positive for legibility: "I'm twelve nested l
by hakfoo 5y ago
I thought that exceptions were intended for the one situation where people more or less agreed goto could be a net positive for legibility: "I'm twelve nested loops in and realize that I can't proceed, how do I bail out?"
The alternative I've seen tends to be something like "set $faulted when you realize something is unrecoverable, then make sure the entire rest of the function checks for it and makes sure not to do anything else if we've already identified a fault."
- throwaway81523 5y agoThere is a trend now to replace goto-like exceptions with compiler-supplied error checks like you describe: http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0709r0.pdf http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0709r0.... This is likely inspired by the Error monad in Haskell, and the doc might say so explicitly (I don't remember).