[Python-ideas] Cofunctions - an enhancement to yield-from
Greg Ewing
greg.ewing at canterbury.ac.nz
Tue Aug 3 03:28:13 CEST 2010
On 03/08/10 04:39, Guido van Rossum wrote:
> The only concrete objection I
> have is that it might be hard to implement in Jython or IronPython
As long as it's possible to implement 'yield from', it should be
possible to implement codef as well.
If nothing else, every call could expand into code that checks
for the presence of __cocall__ and then performs either a
normal call or a yield-from.
Another approach would be to compile all calls as
yield from cowrap(func, args...)
where cowrap is defined something like
def cowrap(func, *args, **kwds):
if hasattr(func, '__cocall__'):
return yield from func.__cocall__(*args, **kwds)
else:
return func(*args, **kwds)
--
Greg
More information about the Python-ideas
mailing list