Continuations and threads (was Re: Iterators & generators)
Harald Hanche-Olsen
hanche at math.ntnu.no
Thu Feb 17 17:36:48 EST 2000
+ Mike Fletcher <mfletch at tpresence.com>:
| Not being a CS person, maybe I can confuse the issue :) ...
I'm not one either, so surely I can confuse it further!
| A continuation is a suspended execution context, you get to a point
| and say "can't/won't finish this now, I'll store the state (frame)
| and let other execution contexts call me when I should continue".
| When you want to resume the context, you "call" the continuation,
| which resumes running the suspended execution context at the next
| line after the call to suspend.
So far, this is not all that different from
coroutines/generators/threads/whatever. To my mind, one of the
mindboggling things about continuations is that you can call the same
continuation multiple times, whereas when you call a
coroutine/generator, its program counter advances, so that the next
time you call it, you are really calling a new continuation.
| If I'm reading things right, there are methods on continuations
| which allow for updating variables while not running the context, so
| you can pass information into the context while it is suspended.
Well, the global environment can always change between calls, but you
may even have two continuations sharing a lexical environment (i.e.,
they were both generated within the same procedure call), so calling
one can modify the local environment of the other.
maybe-posting-some-Scheme-code-could-obfuscate-the-issue-furhter-ly y'rs,
--
* Harald Hanche-Olsen <URL:http://www.math.ntnu.no/~hanche/>
- "There arises from a bad and unapt formation of words
a wonderful obstruction to the mind." - Francis Bacon
More information about the Python-list
mailing list