The fundamental concept of continuations

josephoswald+gg@gmail.com josephoswald at gmail.com
Tue Oct 9 09:50:03 EDT 2007


On Oct 9, 2:09 am, "." <f... at bar.biz> wrote:
> On Tue, 09 Oct 2007 05:15:49 +0000, gnuist006 wrote:

> > (3) Is it present in python and java ?
>
> Certainly not Java, I dunno about Python.  I've never seen someone use
> them in Python, but the pythonistas seem to want to add everything but a
> decent lambda to their language so I wouldn't be surprised if someone had
> added a call/cc.  Ruby has it.
>

Continuations exist in all computer languages---actually, in anything
that executes code. The continuation is simply "what will happen for
the rest of the program execution." What might or might not exist is
an explicit linguistic mechanism to examine it, refer to the
continuation as a function, or to save it for later use.

> > (4) Its implementation in assembly. for example in the manner that
> > pointer fundamentally arises from indirect addressing and nothing new.
> > So how do you juggle PC to do it.
>

The continuation is typically present in the stack, which contains all
the control-flow information needed to continue program execution from
this point. (I.e., the function call mechanism includes a step saving
the location of the instruction to execute when the function call is
complete, and any registers that it will restore after the function
returns because the function call might destroy them.)

How you save that continuation for later, possibly repeated, use from
a different location in the program is a different question.




More information about the Python-list mailing list