Continuations and threads (was Re: Iterators & generators)
Christian Tismer
tismer at tismer.com
Fri Feb 18 10:00:12 EST 2000
Gordon McMillan wrote:
>
> Toby Dickenson wrote:
>
> > What are the implications for the continuation-naive in a
> > post-stackless world. What about functions such as...
> >
> > def x():
> > before()
> > try:
> > y()
> > finally:
> > after()
> >
> > Today, either of three things happen:
> > 1. before() throws
> > 2. before() and after() are called exactly once each
> > 3. x() never returns because y() never returns
> >
> > As I understand continuations, we now have the possibility of y()
> > returning more than once, with after() called more times than before()
>
> No. In the absence of specific instructions otherwise, the
> frame dispatcher will behave as expected.
I think Toby meant it this way:
consider a weird y() defined as follows
def y():
global gotcha
try:
gotcha
except:
gotcha = continuation.caller()
This thingie will save its caller's continuation when run
for the first time. Later on you can simply call
gotcha()
and we are backt at y's call, reciting Toby:
> > y()
> > finally:
> > after()
In other words, we can leave the function more often
than we entered it :-)
ciao - chris
--
Christian Tismer :^) <mailto:tismer at appliedbiometrics.com>
Applied Biometrics GmbH : Have a break! Take a ride on Python's
Kaunstr. 26 : *Starship* http://starship.python.net
12163 Berlin : PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF
we're tired of banana software - shipped green, ripens at home
More information about the Python-list
mailing list