Re: FW: FW: [Python-Dev] Simple generator implementation

To a decent extent, based on reading your posts carefully.
Based on a discussion with Christian at IPC9, they are. I should have been more clear about that. My main need is to be able to change a bit of context and invoke a different execution path, without going through the full overhead of a function call. XSLT, if written "naturally", tends to involve huge numbers of such tweak-context-and-branch operations.
Suspending only to the invoker should do the trick because it is typically a single XSLT instruction that governs multiple tree-operations with varied context. At IPC9, Guido put up a poll of likely use of stackless features, and it was a pretty clear arithmetic progression from those who wanted to use microthreads, to those who wanted co-routines, to those who wanted just generators. The generator folks were probably 2/3 of the assembly. Looks as if many have decided, and they seem to agree with you. -- Uche Ogbuji Principal Consultant uche.ogbuji@fourthought.com +1 303 583 9900 x 101 Fourthought, Inc. http://Fourthought.com 4735 East Walnut St, Ste. C, Boulder, CO 80301-2537, USA Software-engineering, knowledge-management, XML, CORBA, Linux, Python

Can I make a suggestion: If we're going to get this generator stuff, I think it would read better if the suspending statement were yield x rather than suspend x because x is not the thing that we are suspending! Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg@cosc.canterbury.ac.nz +--------------------------------------+

Greg Ewing <greg@cosc.canterbury.ac.nz> wrote:
I agree; this really improves readability. I'm sure someone knows of precedence for the "suspend" keyword, but the only one I recall seeing before is "yeild" (Sather). -Fred -- Fred L. Drake, Jr. <fdrake at acm.org> PythonLabs at Digital Creations

Greg Ewing <greg@cosc.canterbury.ac.nz> wrote:
Fred Drake wrote:
I agree; this really improves readability.
Indeed, shortly after i wrote my generator examples, i wished i'd written "generate x" rather than "suspend x". "yield x" is good too. -- ?!ng Happiness comes more from loving than being loved; and often when our affection seems wounded it is only our vanity bleeding. To love, and to be hurt often, and to love again--this is the brave and happy life. -- J. E. Buchrose

the real fred wrote:
I agree; this really improves readability. I'm sure someone knows of precedence for the "suspend" keyword
Icon (the suspend keyword "leaves the generating function in suspension")
but the only one I recall seeing before is "yeild" (Sather).
I associate "yield" with non-preemptive threading (yield to anyone else, not necessarily my caller). Cheers /F

Fredrik Lundh <fredrik@effbot.org>:
I associate "yield" with non-preemptive threading (yield to anyone else, not necessarily my caller).
Well, this flavour of generators is sort of a special case subset of non-preemptive threading, so the usage is not entirely inconsistent. Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg@cosc.canterbury.ac.nz +--------------------------------------+

On Thu, Mar 22, 2001 at 01:39:05PM +1200, Greg Ewing wrote:
Fredrik Lundh <fredrik@effbot.org>:
I associate "yield" with non-preemptive threading (yield to anyone else, not necessarily my caller).
I prefer yield, but I'll yield to suspend as long as we get coroutines or suspendable frames so I can finish my Python-embedded MUX with task-switching Python code :-) -- Thomas Wouters <thomas@xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread!

I also like "yield", but when talking about Icon-style generators to people who may not be familiar with them, I'll continue to use "suspend" (since that's the word they'll see in the Icon docs, and they can get many more examples from the latter than from me).

On the subject of keyword preferences, I like yield best because I first saw iterators (Icon's generators) in CLU and CLU uses yield. Jeremy

Jeremy Hylton:
On the subject of keyword preferences, I like yield best because I first saw iterators (Icon's generators) in CLU and CLU uses yield.
For me the benefit of "yield" is that it connotes both transfer of value and transfer of control, just like "return", while "suspend" only connotes transfer of control. "This tree yields 20 Kilos of fruit each year" and "When merging, yield to the vehicles to your right". Neil

Uche Ogbuji wrote:
Here the exact facts of the poll: microthreads: 26 co-routines: 35 generators: 44 I think this reads a little different. ciao - chris -- Christian Tismer :^) <mailto:tismer@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/

[Tim]
[Uche Ogbuji]
Thank you for explaining more! It's helpful.
They can't: I haven't taken a position <0.5 wink>. As I said, I'm trying to get closer to understanding the cost/benefit tradeoffs here. I've been nagging in favor of simple generators for a decade now, and every time I've tried they've gotten hijacked by some grander scheme with much muddier tradeoffs. That's been very frustrating, since I've had good uses for simple generators darned near every day of my Python life, and "the only thing stopping them" has been a morbid fascination with Scheme's mistakes <wink>. That phase appears to be over, and *now* "the only thing stopping them" appears to be a healthy fascination with coroutines and uthreads. That's cool, although this is definitely a "the perfect is the enemy of the good" kind of thing. trying-leave-a-better-world-for-the-children<wink>-ly y'rs - tim

Can I make a suggestion: If we're going to get this generator stuff, I think it would read better if the suspending statement were yield x rather than suspend x because x is not the thing that we are suspending! Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg@cosc.canterbury.ac.nz +--------------------------------------+

Greg Ewing <greg@cosc.canterbury.ac.nz> wrote:
I agree; this really improves readability. I'm sure someone knows of precedence for the "suspend" keyword, but the only one I recall seeing before is "yeild" (Sather). -Fred -- Fred L. Drake, Jr. <fdrake at acm.org> PythonLabs at Digital Creations

Greg Ewing <greg@cosc.canterbury.ac.nz> wrote:
Fred Drake wrote:
I agree; this really improves readability.
Indeed, shortly after i wrote my generator examples, i wished i'd written "generate x" rather than "suspend x". "yield x" is good too. -- ?!ng Happiness comes more from loving than being loved; and often when our affection seems wounded it is only our vanity bleeding. To love, and to be hurt often, and to love again--this is the brave and happy life. -- J. E. Buchrose

the real fred wrote:
I agree; this really improves readability. I'm sure someone knows of precedence for the "suspend" keyword
Icon (the suspend keyword "leaves the generating function in suspension")
but the only one I recall seeing before is "yeild" (Sather).
I associate "yield" with non-preemptive threading (yield to anyone else, not necessarily my caller). Cheers /F

Fredrik Lundh <fredrik@effbot.org>:
I associate "yield" with non-preemptive threading (yield to anyone else, not necessarily my caller).
Well, this flavour of generators is sort of a special case subset of non-preemptive threading, so the usage is not entirely inconsistent. Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg@cosc.canterbury.ac.nz +--------------------------------------+

On Thu, Mar 22, 2001 at 01:39:05PM +1200, Greg Ewing wrote:
Fredrik Lundh <fredrik@effbot.org>:
I associate "yield" with non-preemptive threading (yield to anyone else, not necessarily my caller).
I prefer yield, but I'll yield to suspend as long as we get coroutines or suspendable frames so I can finish my Python-embedded MUX with task-switching Python code :-) -- Thomas Wouters <thomas@xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread!

I also like "yield", but when talking about Icon-style generators to people who may not be familiar with them, I'll continue to use "suspend" (since that's the word they'll see in the Icon docs, and they can get many more examples from the latter than from me).

On the subject of keyword preferences, I like yield best because I first saw iterators (Icon's generators) in CLU and CLU uses yield. Jeremy

Jeremy Hylton:
On the subject of keyword preferences, I like yield best because I first saw iterators (Icon's generators) in CLU and CLU uses yield.
For me the benefit of "yield" is that it connotes both transfer of value and transfer of control, just like "return", while "suspend" only connotes transfer of control. "This tree yields 20 Kilos of fruit each year" and "When merging, yield to the vehicles to your right". Neil

Uche Ogbuji wrote:
Here the exact facts of the poll: microthreads: 26 co-routines: 35 generators: 44 I think this reads a little different. ciao - chris -- Christian Tismer :^) <mailto:tismer@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/

[Tim]
[Uche Ogbuji]
Thank you for explaining more! It's helpful.
They can't: I haven't taken a position <0.5 wink>. As I said, I'm trying to get closer to understanding the cost/benefit tradeoffs here. I've been nagging in favor of simple generators for a decade now, and every time I've tried they've gotten hijacked by some grander scheme with much muddier tradeoffs. That's been very frustrating, since I've had good uses for simple generators darned near every day of my Python life, and "the only thing stopping them" has been a morbid fascination with Scheme's mistakes <wink>. That phase appears to be over, and *now* "the only thing stopping them" appears to be a healthy fascination with coroutines and uthreads. That's cool, although this is definitely a "the perfect is the enemy of the good" kind of thing. trying-leave-a-better-world-for-the-children<wink>-ly y'rs - tim
participants (10)
-
Christian Tismer
-
Fred L. Drake
-
Fredrik Lundh
-
Greg Ewing
-
Jeremy Hylton
-
Ka-Ping Yee
-
Neil Hodgson
-
Thomas Wouters
-
Tim Peters
-
Uche Ogbuji