(root)/Notes/Notes/notes/exception.md RSS

Exception

try-catch the language construct

see null, continuation

c's setjmp and longjmp were discovered: they're just a save-and-restore of the instruction and stack pointers. but try-catch the language construct, was invented

the central problem with using exceptions for error handling is that errors are not exceptional --- https://youtu.be/sbVxq7nNtgo?t=2m3s. assuming the "happy path" and handling other cases by breaking normal control flow is not smart. that said, sometimes, breaking normal control flow and longjmping somewhere up the stack---regardless of whether errors are involved---is the most practical solution. and in those distinguished cases, exceptions become a useful tool

example my continuation›-passing style regular expression engine reports matches and backtracks possessive quantifiers by longjmping up the stack --- https://github.com/Bricktech2000/CPS-RE/blob/6e5535e73bc449c8e41c4c31cc0c7d7e3f15a973/cps-re.c#L23-L48