Continuations and threads (was Re: Iterators & generators)
Thomas Wouters
thomas at xs4all.net
Fri Feb 18 10:41:58 EST 2000
More information about the Python-list mailing list
Fri Feb 18 10:41:58 EST 2000
- Previous message (by thread): Continuations and threads (was Re: Iterators & generators)
- Next message (by thread): Continuations and threads (was Re: Iterators & generators)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Feb 17, 2000 at 05:36:48PM -0500, Harald Hanche-Olsen wrote: > + 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! I may be too confused to tell for sure, but i have a gut feeling that i'm getting closer and closer to some complete and utterly consistent cluelessness of this issue. Pauls' posting on continuations, more or less describing C's set/longjmp, helped a lot at getting my mind wrapped around this idea, but as Tim suggested, I'm not quite warped enough to understand the basics of it all. (That is, I'm assuming here you all, especially Tim, speak the truth, and this continuations business isn't some huge PSU conspiracy to scare the bejezes out of everyone, to make sure continuations do _not_ make it into Python ;) > | 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 this is so, you could see 'a continuation' as a class of object that is defined in a running process, and when instantiated produces a python (thread ? process ? stackframe ? what can i call it that doesn't already have a different meaning ? :) - a python 'execution line' including local variables, but not global ones, starting from the point defined in the continuation-class (which is one instruction past the magic definition of the continuation-class) where each 'instance' of the specific continuation-class is actually executed 'in' a seperate frame object -- changes to local variables have no effect on another 'instance' of the continuatio-class, but global ones do. And the continuation-class stays valid regardless of what other instances of the continuation or other parts of the program do ? What would a traceback generated by an exception in a continuation look like, by the way ? (a lot more questions about how it would look if you did <this> or <that> come to mind, but i'm also thinking up possible answers to them, and i think most of them are implementation defined anyway ;) I'm probably looking at this all wrong -- i fail to see how this is more abstract, more theoretical, more low-level, than simple subroutines. (Though i must admit my idea of subroutines is probably all wrong -- i'm thinking of C functions, including stack and all that.) Is there any chance that someone can explain continuations either in a very pythonic sense (which would require a large leap of imagination to start with) or at a very basic level, like the example of coroutines in Compass that Harald posted -- i found that *very* enlightening. If course, someone (i.e. Tim) is going to smash all my hope by saying that there is no simple way to explain continuations. Can't someone do a very simple example using toy cars, road crossings, chickens, idiot drivers and/or huge kerosine-carrying tankertrucks ? Something that might not be much clearer but sheds some very different light on the issue, and caters to the simple minds ? ;P > maybe-posting-some-Scheme-code-could-obfuscate-the-issue-furhter-ly y'rs, Probably, except that i dont know any Scheme, so it would probably fail to confuse me (unless it has well-known keywords do something not-very-well-known ;) I'm really curious about continuations. I also (now) have a weird idea of continuations, probably all wrong, that makes me wonder slightly "this is very simple, what is the big fuss ? where is the rest hiding ?" -- except for Tim explicitly stating that the idea I have of continuations is wrong;) Continuous-ly y'rs, -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
- Previous message (by thread): Continuations and threads (was Re: Iterators & generators)
- Next message (by thread): Continuations and threads (was Re: Iterators & generators)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list