6 ms·
Lisp-style conditions are implementable even over C setjmp and longjmp style control. The non-unwinding part is done by searching the chain of frames and calli
by kazinator 8y ago
Lisp-style conditions are implementable even over C setjmp and longjmp style control.
The non-unwinding part is done by searching the chain of frames and calling functions, without taking any non-local control transfer.
The frame linkage is assisted by maintaining a global or thread-specific stack top variable. A frame is declared on the stack, then hooked into the list using the global variable. When a control transfer does take place, the value of that variable is properly maintained to discard the frames that are in functions being abandoned.
Source: been there, implemented that.
I'm not that familiar with go but from what I remember of the descriptions of panic/recover, something similar should be doable.