[Python-Dev] Naming comprehension syntax [was Re: Informal educator feedback on PEP 572 ...]

Ivan Pozdeev vano at mail.mipt.ru
Fri Jul 6 22:52:53 EDT 2018


https://github.com/python/cpython/pull/8145

On 07.07.2018 3:33, Ivan Pozdeev via Python-Dev wrote:
> On 07.07.2018 2:58, Ivan Pozdeev via Python-Dev wrote:
>> On 07.07.2018 2:31, Guido van Rossum wrote:
>>> On Fri, Jul 6, 2018 at 4:19 PM Terry Reedy <tjreedy at udel.edu 
>>> <mailto:tjreedy at udel.edu>> wrote:
>>>
>>>     Since Guido, the first respondent, did not immediately shoot the
>>>     idea
>>>     down, I intend to flesh it out and make it more concrete.
>>>
>>>
>>> Maybe I should have shot it down. The term is entrenched in multiple 
>>> languages by now (e.g. 
>>> https://en.wikipedia.org/wiki/List_comprehension). Regarding "list 
>>> builder" one could argue that it would just add more confusion, 
>>> since there's already an unrelated Builder Pattern 
>>> (https://en.wikipedia.org/wiki/Builder_pattern) commonly used in 
>>> Java. (Though I worry about the presence of a Python example in that 
>>> Wikipedia page. :-)
>>
>> According to 
>> https://en.wikipedia.org/wiki/List_comprehension#History, the term's 
>> known from at least 1977 and comes from such influential languages as 
>> NPL, Miranda and Haskell. So it's not you to blame for it :-)
>>
>>>
>>> Also, "generator builder" is not much more expressive than 
>>> "generator expression",
>>
>> "generator builder" is simply incorrect. The GE doesn't "build" 
>> generators, it's a generator itself. It's a generator _and_ an 
>> expression. What could be a more obvious name?
>> This suggestion looks like coming from someone who hasn't quite 
>> grasped generators yet.
>>
>>> and the key observation that led to this idea was that it's such a 
>>> mouthful to say "comprehensions and generator expressions".
>>
>> Since "X comprehensions" are advertised as and intended to be 
>> functionally equivalent to `X(generator expression)', I use just 
>> "generator expressions" to refer to all.
>> That's accurate because the common part with the distinctive syntax 
>> -- which is the thing referred to when addressing them all -- 
>> effectively _is_ a generator expression (the syntax differences in 
>> the leading term are insignificant), what wraps it is of no concern.
>>
>> So, no new terms are necessary, but someone who cares may add a note 
>> to the docs to this effect.
>>
>
>>> Maybe it's not too late to start calling the latter "generator 
>>> comprehensions" so that maybe by the year 2025 we can say 
>>> "comprehensions" and everyone will understand we mean all four types?
>>>
> https://docs.python.org/3/reference/expressions.html?highlight=comprehension#displays-for-lists-sets-and-dictionaries
>
> Oh, I see. So, "comprehension" is actually the official term for this 
> "distinctive syntax", and the fact that "generator expressions" came 
> to use it is but a coincidence.
>
> In that case, we can do a Solomon's decision: mention _both_ that 
> "comprehension" is the official term for the syntax in GE's reference 
> entry, _and_ the fact that "X comprehensions" are effectively wrapped 
> GEs in their reference entries.
>
> Then everyone will learn both terminologies and could choose which is 
> more convenient to use.
>
>>> FWIW more people should start using "list display" etc. for things 
>>> like [a, b, c].
>>> -- 
>>> --Guido van Rossum (python.org/~guido <http://python.org/%7Eguido>)
>>>
>>>
>>> _______________________________________________
>>> Python-Dev mailing list
>>> Python-Dev at python.org
>>> https://mail.python.org/mailman/listinfo/python-dev
>>> Unsubscribe:https://mail.python.org/mailman/options/python-dev/vano%40mail.mipt.ru
>>
>>
>>
>> _______________________________________________
>> Python-Dev mailing list
>> Python-Dev at python.org
>> https://mail.python.org/mailman/listinfo/python-dev
>> Unsubscribe:https://mail.python.org/mailman/options/python-dev/vano%40mail.mipt.ru
>
>
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: https://mail.python.org/mailman/options/python-dev/vano%40mail.mipt.ru

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180707/197ffabb/attachment-0001.html>


More information about the Python-Dev mailing list