Thanks John. That does still leave me with one question: >Variables that are above >the point where the continuation was captured cannot be restored if they have been changed.
This seems to imply that the state of variables in the scope the continuation was captured are restored with the continuation, but the state of variables in scopes higher up the stack are not. But that doesn't sound right. If the continuation is copying the entire stack, than every single lexical variable would have its state restored when the continuation was restored, all the way up to toplevel. So if that wasn't what you meant, than what did you mean? On Sat, Jul 16, 2016, 21:40 John Cowan <[email protected]> wrote: > Josh Barrett scripsit: > > > A continuation is a capture of your location in a program, and its > pending > > operations to return a result. In other languages, this is often > > represented by the stack. > > > > When a continuation is captured, the current state of the stack is > captured > > and can be restored later. > > So far so good. > > > The value of variables within the scope of the continuation are not > > captured: if variables are initialized within a lexical context, a > > continuation of that context is captured, the values of those variables > are > > altered, and the continuation is restored, the variables will not reset > to > > their original values. > > No, this is not true. The local variables are also on the stack and > are captured along with the return addresses. Variables that are above > the point where the continuation was captured cannot be restored if they > have been changed. > > > In chicken, capturing a continuation is cheap, because you need only > take a > > pointer to a set of data, and register that with the GC. In most other > > scheme implementations, escpecially those with a stronger focus on C > > interop, capturing a continuation is expensive, because you need to copy > > the entire program stack. > > There are ways to make it cheaper, but basically yes. In Chicken, you pay > for cheap continuations by occasionally paying much more for ordinary > procedure calls (those that fill the C stack and trigger minor garbage > collections). In other systems, programs that don't capture continuations > don't pay for them. > > -- > John Cowan http://www.ccil.org/~cowan [email protected] > Is not a patron, my Lord [Chesterfield], one who looks with unconcern > on a man struggling for life in the water, and when he has reached ground > encumbers him with help? --Samuel Johnson >
_______________________________________________ Chicken-users mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/chicken-users
