On Fri, Oct 15, 2010 at 10:22 AM, B. Estrade <estr...@gmail.com> wrote: > Pardon my ignorance, but are continuations the same thing as > co-routines, or is it more primitive than that?
Continuations are not the same thing as coroutines, although they can be used to implement coroutines - in fact, continuations can be used to implement any sort of flow control whatsoever, because they are a way of generalizing flow control. Goto's, function calls, coroutines, setjmp/longjmp, loops, exception throwing and catching - these and more can all be regarded as special cases of continuation manipulation. A continuation is just a snapshot of a point in a program's run, which can then be 'called' later to return control to that point. The entire execution context is preserved, so you can call the same continuation multiple times, re-enter a function that has already returned, etc. But state changes are not undone, so the program can still behave differently after the continuation is called. -- Mark J. Reed <markjr...@gmail.com>