4 ms·
Can you explain how continuations apply here. I don't really have a good idea about that. Wrt setjmp/longjmp, I think the key differences are the lack of a 'se
by anonymous246 16y ago
Can you explain how continuations apply here. I don't really have a good idea about that.
Wrt setjmp/longjmp, I think the key differences are the lack of a 'setjmp' and that you don't have to pass in the setjmp buffer down the calls. If you ignore those aspects and focus only the barest essence, yes they're the same (just like nitrogen and a cake are the same because they're both made of protons, neutrons, and electrons).
- silentbicycle 16y agoThink 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.