On Fri, Aug 08, 2003 at 10:26:26PM +0900, djd15 / cwru.edu wrote:
> As I understand it, continuations are, in a way, a
> superset of closures. A continuation creates a
> closure that also has information on where it was
> executing at the time, so when you execute the
> continuation, it goes back to that place, in addition
> to having the appropriate context.

OK. So if you had object or variable x in scope at that time, you still have
access to the same object/variable, but with whatever its *current* value
is. That makes sense.

> I think this makes callcc a bit different than
> setjmp and longjmp from C (although I haven't used
> them, only read about them), as I believe they make
> a copy of, and restore the stack.

I don't think so; AFAIK setjmp just stores the stack pointer and instruction
pointer (and other registers, I guess), and longjmp just restores them. C is
only portable machine-code, after all :-)

As a result, at longjmp the stack is "wound back" to exactly where it was
before. Any local variables declared within nested function calls are
therefore lost. But any variables declared within the current function, or
in functions which call it, or global variables, keep their current values.

Cheers,

Brian.