a simple example of Stackless Python

Christian Tismer tismer at tismer.com
Sun Nov 5 09:49:50 EST 2000


Evan Simpson wrote:
> 
> "June Kim" <junaftnoon at nospamplzyahoo.com> wrote in message
> news:8tjrn2$esm$1 at news.nuri.net...
> > It seems like there are few people who understand Stackless Python
> > and the stuffs, and I'm not one of them. Can anyone explain me
> > this simple code? The paper was not very helpful for me to understand.
> 
> I'll give it a shot. "this = continuation.current()" creates a continuation
> object, and "this.update(n)" does two things: First, it updates the
> continuation object so that calling it will cause program execution to
> continue at that line, as though "this.update(n)" had just returned the
> value passed in the call.  Second, it evaluates to n, so that the line acts
> as though it were "k = n".
...

Thanks a lot for this perfect explanation.

Note that the .update() stuff is quite a hack, born from syntactic
problems to get "at that point in the code below". Continuations
should be immutable snapshots of program state by concept. I'm
breaking it here just to keep a handle for the "=" position,
while passing a value.
This is one of the weakest concepts of Python's continuations,
and it is quite likely to vanish.
Passing continuations explicitly as parameters, or grabbing them
from caller functions via caller() is the desired way of the
still non-existing API.

Back from Turkey I see the Stackless gang did a good job,
thanks again to you all - chris

-- 
Christian Tismer             :^)   <mailto:tismer at tismer.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Kaunstr. 26                  :    *Starship* http://starship.python.net
14163 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     where do you want to jump today?   http://www.stackless.com




More information about the Python-list mailing list