a simple example of Stackless Python

June Kim junaftnoon at nospamplzyahoo.com
Mon Oct 30 22:16:24 EST 2000


"Evan Simpson" <evan at 4-am.com> wrote in message
news:V7oL5.37775$f01.44754 at skycache.prestige.net...
> "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".
>
> Thus, "this(k-1)"  jumps to the "k = this.update(n)" line and makes it act
> as though it were "k = k-1".  It means "continue at the point just after
we
> were updated, with k-1 on top of the stack".
>
> The whole function behaves exactly like:
>
> k = n
> while k:
>   k = k-1
>
> ...and demonstrates how a continuation can be used to construct a simple
> loop.
>

Thank you first of all.
If my understanding is right, what cotinuation objects save is not the
whole context including variables but only the point of execution.
Am I right on this?

Best regards,

June

>
> --
> Cheers,
>
> Evan @ digicool & 4-am
>
>




More information about the Python-list mailing list