3 ms·
>> Throwing an exception is an example of a “non local exit” which Rust also implements (in terms of “Return”). > They are not isomorphic. It was never claime
by CyberRabbi 6y ago
>> Throwing an exception is an example of a “non local exit” which Rust also implements (in terms of “Return”).
> They are not isomorphic.
It was never claimed that “return” and “throw” were isomorphic. Only that they are both examples of non-local exits.
> good evidence for why this behavior is too complicated for its own good.
That’s a nice opinion but I wouldn’t consider that evidence except under the loosest definitions of the word. By the same reasoning I could claim that being able to invoke “return” at any arbitrary point in the function is evidence that return is a complicated feature.
Just like “return” exceptions in C++ have a statically defined set of areas they can branch to and the invocation of throw is well defined w.r.t. to object cleanup. Admittedly those landing sites are more numerous than “return” but not different in their more defining properties.
- arcticbull 6y ago> I could claim that being able to invoke “return” at any arbitrary point in the function is evidence that return is a complicated feature. Not really, because a return statement (like a go-to) only has one place to go. An exception has an unlimited number of places to come from. That put it into its own special circle of hell.
- CyberRabbi 6y agoYour metric of what makes a language feature too complicated is just as arbitrary as mine. > An exception has an unlimited number of places to come from False. An exception can only come from a throw statement, which is both lexical/statically defined and finite in number within every codebase.
- arcticbull 6y ago> False. An exception can only come from a throw statement... Obviously. > ...which is both lexical/statically defined and finite in number within every codebase. Not in every case. Any time you have a library that calls into client code the set is dynamic and uncountable from the perspective of the library author.