[Stackless] Stackless support generator functions?

Aaron Watters aaron at reportlab.com
Mon Sep 30 20:34:03 CEST 2002


Yes we are both right.  But I should have gotten
rid of the global by writing

class ChannelWrapper:
     def __init__(self, channel):
           self.channel = channel
     def __call__(self, value):
           self.channel.send(value)

inOrderMap(tree, ChannelWrapper(channel))

I still maintain that channels are fundamentally more general
in that you can easily emulate "yield" with channels+tasklets but you
can't do the converse.  But I agree there are very many
circumstances where using "yield" directly is clearer and faster.

   -- Aaron Watters

Richard Cooper wrote:

>Quite correct, good example. If you need to pass in a "how to output"
>function the you can't work with yield.
>
>def function4(x):
>      yield x
>
>wouldn't work for (approximately) the same reasons
>
>def function5(x):
>      return x
>
>wouldn't. Functions 1-3 are getting their results out through a globally
>scoped 'thing' (stdout, channel1 and List) where as yield and return get
>results out through the return value. Both are perfectly valid. It's just a
>question of preferred style and using the clearest code for the job in
>hand*. .....
>


_______________________________________________
Stackless mailing list
Stackless at www.tismer.com
http://www.tismer.com/mailman/listinfo/stackless



More information about the Stackless mailing list