[Python-ideas] Cofunctions - A New Protocol

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Nov 2 10:44:28 CET 2011


Terry Reedy wrote:

> Is this really needed? The presence of 'coyield' signals 'cofunction', 
> just as 'yield' signals 'generator'.

The 'coyield' doesn't have to be directly in that function,
it could be in something called by that function, any number
of levels deep.

However, it's since occurred to me that 'coyield' doesn't have
to be a keyword, it could be a built-in cofunction.

>> * A cofunction can only be called from the body of another cofunction,
>> not in
>> any other context.
> 
> Except that an initial 'call' from a coroutine.resume is needed to get 
> the first cofunction started ;-).

Yes, but that's not done using the normal call syntax, which
is what I'm talking about there (that could perhaps be made
clearer).

-- 
Greg




More information about the Python-ideas mailing list