[Python-ideas] PEP 492 terminology - (native) coroutine objects
Steven D'Aprano
steve at pearwood.info
Fri May 1 14:22:22 CEST 2015
On Fri, May 01, 2015 at 12:49:44PM +0100, Oscar Benjamin wrote:
> So if I say that something is a "coroutine" it's really not clear what
> that means. It could mean an an asyncio.coroutine generator function,
> it could mean an async def function or it could mean both. Worse it
> could mean the object returned by either of those types of functions.
I'm sympathetic to your concerns, and I raised a similar issue earlier.
But, it's not entirely without precedence. We already use "generator" to
mean both the generator-function and the generator-iterator returned
from the generator-function. We use "decorator" to mean both the
function and the @ syntax. Sometimes we distinguish between classes and
objects (instances), sometimes we say that classes are objects, and
sometimes we say that classes are instances of the metaclass. "Method"
can refer to either the function object inside a class or the method
instance after the descriptor protocol has run.
And of course, once you start comparing terms from multiple languages,
the whole thing just gets worse (contrast what Haskell considers a
functor with what C++ considers a functor).
It's regretable when language is ambiguous, but sometimes a little bit
of ambiguity is the lesser of the evils. Human beings are usually good
at interpreting that given sufficient context and understanding.
If there is no good alternative to coroutine, we'll need some good
documentation to disambiguate the meanings.
--
Steve
More information about the Python-ideas
mailing list