> > So, here we have a DFA. > > > > The 'continuation' means to freeze the current state of the > > execution. The benefit of the continuations are that you have > > a history of the states, which you had traversed. And like a > > backtracking algorithm, you can go back to a previous state > > and follow another route. > > > > So, the answer is, it is sufficient to have the 'history of > > states' to take a new name like 'continuation' instead of > > simple 'state'? I think yes. > > Sorry, I don't think so. I'm not a specialist in Scheme but I think > there is a concept behind continuations and the general use for all > controllers in Cocoon would be misleading.
Okay, to be sure I googled around, and found: http://www.cs.utexas.edu/users/wilson/schintro/schintro_141.html > call-with-current-continuation > > call-with-current-continuation is a very powerful control construct, > which can be used to create more conventional control constructs, like catch and > throw in Lisp (or setjmp and longjmp in C), or coroutines, and many > more. It is extremely powerful because it allows a program to manipulate its own > control "stack" so that procedure calls and returns needn't follow the > normal depth-first textual call ordering. > > Recall that we said [ WHERE? ] that Scheme's equivalent of an activation > stack is really a chain of partial continuations (suspension records), > and this chain is known as a full continuation. And since continuations are > immutable, they usually form a tree reflecting the call graph (actually, > only the non-tail calls). Normally, the parts of this tree that are not > in the current continuation chain are garbage, and can be garbage > collected. > > If you take a pointer to the current continuation, and put it in a live > variable or data structure, however, then that continuation chain will > remain live and not be garbage collected. That is, you can "capture" the > current state of the stack. It is not exactly what I want, but the core statement is 'A continuation is chain of partial continuations, or captured states of the stack' I think :) But maybe I'm wrong?! It's funny, but the whole continuation concept reminds me of the Tomita algorithm for simulating a GLR parser, which I currently working on ;-) http://www.cs.rhul.ac.uk/research/languages/publications/tomita_style_1.ps Stephan.