[Python-ideas] Cofunctions PEP - Revision 4

Nick Coghlan ncoghlan at gmail.com
Thu Aug 12 23:39:55 CEST 2010

On Thu, Aug 12, 2010 at 10:51 PM, Greg Ewing
<greg.ewing at canterbury.ac.nz> wrote:
> Nick Coghlan wrote:
>> Without send() and throw(), an object is just an iterator, never a
>> cofunction (as there is no way for it to make cooperative calls - you
>> need the extra two methods in order to receive the results of any such
>> calls).
> There are plenty of uses for cofunctions that never send or
> receive any values using yield, but just use it as a suspension
> point. In that case, send() is never used, only next(). And
> I suspect that use of throw() will be even rarer.

Could you name some of those uses please? If you aren't getting
answers back, they sound like ordinary iterators to me. The whole
*point* of cofunctions to my mind is that they let you do things like
async I/O (where you expect a result back, in the form of a return
value or an exception) in a way that feels more like normal imperative

So, you may consider there to be plenty of uses for iterate-only
cofunctions, but I come up blank.


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-ideas mailing list