[Python-ideas] Cofunctions - Back to Basics

Nick Coghlan ncoghlan at gmail.com
Sat Oct 29 16:48:13 CEST 2011


On Sat, Oct 29, 2011 at 8:51 PM, Paul Moore <p.f.moore at gmail.com> wrote:
> I think that if the runtime support can be built in a way that allows
> a Lua-style function/method approach, then that should be the initial
> design, as it's easier to tweak a functional API than to change
> syntax. If experience shows that code would benefit from syntax
> support, add that later.

I have one specific reason I think the new yield variant should get a
new keyword: it's a new kind of flow control, and Python has a history
of trying to keep flow control explicit (cf. the PEP 343 with
statement discussions).

At the *call* level, it wouldn't need a keyword, since cocall(x) could
just be a wrapper around x.__cocall__().

This would be similar to the situation with generators - yielding from
a generator has dedicated syntax (in the form of 'yield'), but
invoking one just uses the standard call and iterator syntax.

Cheers,
Nick.

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



More information about the Python-ideas mailing list