Continuations

Christian Tismer tismer at tismer.com
Mon Jan 20 08:57:58 EST 2003


Gregor wrote:
> I came across an introduction to Stackless Python and continuations which 
> piqued my interest. It gave the following example to illustrate how a 
> continuation works:

Please note that I don't support continuations
any longer.

> def looptest(n):
> 
>     this = continuation.current()
> 
>     k = this.update(n)
>       # continuation at "="
>     if k:
>         this(k-1)
>         # resuming at "="
>     else:
>         del this.link
> 
> 
> Can anyone tell what "this.update(n)" is, does, or represents? I 
> understand the basic idea of what a continuation is, but that by itself 
> isn't enough background for me to guess what all the terms mean.

Continuations are immutable, by definition.
The example above need to update, in order to catch
the continuation exactly at the position of the equals
sign. This is the point where execution should be resumed.
I didn't find a better way to express this.
This cannot be found anywhere in the literatore since
I invented it.

And it is too hard to explain, therefore I dropped it.

> Every introduction to continuations I've found either describes it using 
> Scheme, which I haven't touched in a decade, and which I suspect most 
> people haven't worked with at all, or re-uses the above Python example 
> with little explanation.

In Scheme, it is easier to express, and you don't need
tricks like above.
While Python doesn't need continuations.
Stackless focuses on tasklets and channels, now.

ciao - chris

-- 
Christian Tismer             :^)   <mailto:tismer at tismer.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34  home +49 30 802 86 56  pager +49 173 24 18 776
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/






More information about the Python-list mailing list