[Python-ideas] Cofunctions - an enhancement to yield-from

ghazel at gmail.com ghazel at gmail.com
Tue Aug 3 08:16:58 CEST 2010


On Mon, Aug 2, 2010 at 11:17 PM, Gregory Ewing
<greg.ewing at canterbury.ac.nz> wrote:
> Would you be interested in a system which requires marking
> calls to coroutines, but tells you immediately when you
> have forgotten to mark such a call?
>
> It might work something like this:
>
> 1. In a cofunction, a call to another cofunction must
>   be marked with 'cocall', e,g.
>
>   z = cocall f(x, y)
>
> 2. Cofunctions *cannot* be called normally -- they do
>   not have a __call__ method, only a __cocall__ method.
>
> So if you try to call a cofunction without using cocall,
> you get an exception. If you try to call an ordinary function
> using cocall, you get an exception. If you try to use cocall
> but forget to declare the function with codef, you get an
> exception (because cocall would only be allowed inside a
> cofunction).

I like this idea.

-Greg



More information about the Python-ideas mailing list