gnu-arch-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnu-arch-users] Re: arch roadmap 1 (and "what's tom up to")


From: Stefan Monnier
Subject: [Gnu-arch-users] Re: arch roadmap 1 (and "what's tom up to")
Date: 12 Jul 2004 16:19:53 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

>> and continuations in a simple (rather than heavily optimized) interpreter
>> was fairly absurd at the time;

> That's it, I'll play the dope. What are continuations?

You can think of it as an object that holds "stack+registers+pc" and to
which you can jump.  Like the jmp_buf returnd by setjmp and passed to
longjmp but with the difference that you can call it as many times as you
want and you can call it even after you returned from the function in which
the setjmp call was made (which has significant implications for how to
manage stack frames).

With it, you can implement backtracking, exceptions, coroutines, ...
You can also write truly horrendously unreadable code (even better than with
good'ol goto).

Why "continuation"?  Well, when you call a function, you pass it
a stack, registers, and a return address, which together represent "what to
do when the called function is done", i.e. the "continuation" of
the computation.  In this sense, functions never "return to their caller"
but instead they "call the caller-provided continuation".

The concept is pretty clean and is generally described independently from
ugly implementation details such as registers and stacks (within the lambda
calculus, for example).


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]