3 ms·
> "setjmp" and "longjmp" are the mechanism for implementing exceptions in C Correct, but reductive. They can be used for many other things.
by ur-whale 4y ago
> "setjmp" and "longjmp" are the mechanism for implementing exceptions in C
Correct, but reductive.
They can be used for many other things.
- adrian_b 4y agoThe more general POV is that "setjmp" defines a continuation and "longjmp" invokes it. While the most frequent use of explicit continuations is for implementing exceptions, you are right that there are many other programming techniques based on explicit continuations (for instance coroutines).
- someweirdperson 4y ago> They can be used for many other things. The underlying primitive offers even more flexibility, but exceptions (in the sense of programming languages) can also be used for many other things than exceptions (in the sense of natural language, to handle exceptional cases).
- bogomipz 4y ago>"... but exceptions (in the sense of programming languages) can also be used for many other things than exceptions ..." Can you elaborate? What are the other ways exceptions are used when not used to handle exceptional situations?