[Python-ideas] Cofunctions without codef

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Aug 11 07:45:58 CEST 2010


I think I may have found a way to eliminate the need for
the 'codef' keyword. I realised that although it's important
to prevent making a regular call to a cofunction, there's
no need to prevent making a cocall to an ordinary function.
In that case, it can just be treated like a normal call.

So I suggest the following changes:

1. The presence of 'cocall' inside a function causes it
    to be a cofunction. There is no 'codef' keyword.

2. The 'cocall' construct checks whether the function
    supports cocalls, and if so, proceeds as previously
    specified. Otherwise, it calls the function normally
    and returns the result.

(To allow for objects such as bound methods to wrap things
which could be cofunctions or not, the __cocall__ method
will be permitted to return NotImplemented as a way of
signalling that cocalls are not supported.)

Does this scheme sound any better?

-- 
Greg



More information about the Python-ideas mailing list