On 10/7/05, Piet Delport <[EMAIL PROTECTED]> wrote:
> Earlier this week, i proposed legalizing "return Result" inside a generator,
> and making it act like "raise StopIteration( Result )", for exactly this 
> reason.
>
> IMHO, this is an elegant and straightforward extension of the current
> semantics of returns inside generators, and is the final step toward making
> generator-based concurrent tasks[1] look just like the equivalent synchronous
> code (with the only difference, more-or-less, being the need for appropriate
> "yield" keywords, and a task runner/scheduler loop).
>
> This change would make a huge difference to the practical usability of these
> generator-based tasks.  I think they're much less likely to catch on if you
> have to write "raise StopIteration( Result )" (or "_return( Result )") all the
> time.
>
> [1] a.k.a. coroutines, which i don't think is an accurate name, anymore.

Before we do this I'd like to see you show some programming examples
that show how this would be used. I'm having a hard time understanding
where you would need this but I realize I haven't used this paradigm
enough to have a good feel for it, so I'm open for examples.

At least this makes more sense than mapping "return X" into "yield X;
return" as someone previously proposed. :)

--
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to