A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-April/052889.html below:

[Python-Dev] Re: anonymous blocks

[Python-Dev] Re: anonymous blocksPhillip J. Eby pje at telecommunity.com
Mon Apr 25 05:32:30 CEST 2005
At 04:57 PM 4/24/05 -0700, Guido van Rossum wrote:
>So a block could return a value to the generator using a return
>statement; the generator can catch this by catching ReturnFlow.
>(Syntactic sugar could be "VAR = yield ..." like in Ruby.)

[uncontrolled drooling, followed by much rejoicing]

If this were available to generators in general, you could untwist 
Twisted.  I'm basically simulating this sort of exception/value passing in 
peak.events to do exactly that, except I have to do:

     yield somethingBlocking(); result=events.resume()

where events.resume() magically receives a value or exception from outside 
the generator and either returns or raises it.  If next()-with-argument and 
next_ex() are available normally on generators, this would allow you to 
simulate co-routines without the events.resume() magic; the above would 
simply read:

     result = yield somethingBlocking()

The rest of the peak.events coroutine simulation would remain around to 
manage the generator stack and scheduling, but the syntax would be cleaner 
and the operation of it entirely unmagical.

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4