16 ms·
How would you implement defer with setjmp/longjmp? I can’t think of anything off the top of my head.
by saagarjha 7y ago
How would you implement defer with setjmp/longjmp? I can’t think of anything off the top of my head.
- simias 7y agoYou'd probably have to #define "return" to call longjmp instead. Although I guess at this point you might be better off just have return call the cleanup code. You'd have to be careful to handle the nesting correctly though, which might be slightly easier with setjmp contexts.