3 ms·
In TXR Lisp, I came up with a way to get (delimited) continuations to play along with unwind-protect and exceptions. The key is to regard continuations as time
by kazinator 9y ago
In TXR Lisp, I came up with a way to get (delimited) continuations to play along with unwind-protect and exceptions.
The key is to regard continuations as time slices of green threads. Now in a thread, we (of course!) do not dispose of the local resources just because we have context switched to another thread!
So I decided to try the same thing with continuations, and it works fairly well.
I augmented the language run-time with a non-unwinding dynamic escape operator. I call the non-unwinding form of escape "absconding". The operator is abscond-from, contrasting with return-from.
Using absconding, we can yield a continuation out of some contour without bailing the local resources, and then use the continuation to come back in. (This is not unlike a context switch out of and back to a thread.)
All the normal call and return mechanisms in the code that we are suspending and resuming with continuations perform normal unwinding.
http://nongnu.org/txr/txr-manpage.html#N-01C4E6B4 http://nongnu.org/txr/txr-manpage.html#N-01C4E6B4
It's a Solved Problem, as far as I'm concerned.