3 ms·
Think of a first class continuation as a heap-allocated setjmp buffer - rather than unwinding the stack, it changes the stack to a saved stack (which, since it
by silentbicycle 16y ago
Think of a first class continuation as a heap-allocated setjmp buffer - rather than unwinding the stack, it changes the stack to a saved stack (which, since it isn't unwound, can be returned to multiple times).
Continuations and longjmp can't return an arbitrary number of levels up the call stack without placing some sort of marker there first, but IMHO that's a good thing. Continuations are a "structured" version of that Tcl return construct. While I haven't done much with Tcl, is it typically used to implement other language constructs with more specific semantics, or is it typically used directly?
- anonymous246 16y agoI've never seen it used (except by myself once). :) Because the control flow becomes hard to understand, and the called function becomes extremely context sensitive. But I think it has its uses within libraries' private functions or in code which can afford to be blub-incompatible.