Proposed new syntax

Terry Reedy tjreedy at udel.edu
Mon Aug 14 13:04:40 EDT 2017


On 8/14/2017 5:59 AM, Ben Finney wrote:

> At what point will you accept the feedback: That the comprehension
> syntax *does not* necessarily connote a procedural loop, but instead can
> quite reasonably be interpreted as its designer intended, a single
> conceptual operation.

In a world where functions have 'side-effects', which is to say, 
implicit inputs and outputs, procedural order is necessary for 
predictable outcomes.  The 'single conception operation' is ambiguious.

Suppose stdin contains "a\nb\nc\nd\ne\nf\ng\n".
What is the meaning of
[input(f"response{i}") for i in range(6)]?
In Python, the predictable result is
['a', 'b', 'c', 'd', 'e', 'f']
It would not be with some of Rustom Mody's 'equivalents'.
Or let L = <list above>.
This implementation of list reversal: [L.pop() for i in range(len(L))]

Do not functional languages define comprehensions in terms of recursion, 
equivalent to for loops?

-- 
Terry Jan Reedy




More information about the Python-list mailing list