[Python-ideas] Assignments in list/generator expressions

Laura Creighton lac at openend.se
Mon Apr 11 01:08:08 CEST 2011


In a message of Sun, 10 Apr 2011 14:31:38 EDT, Eugene Toder writes:
<snip>
>It's well known that minor syntax details cause a lot of disagreement
>(http://www.haskell.org/haskellwiki/Wadlers_Law), so that's not very
>surprising. However, are you sure you're not confusing python's with
>statement and 'with' word in my email, which is simply a placeholder
>for appropriate keyword to mirror Haskell's 'let'? Or was this just an
>occasion to complain about with statement abuse, unrelated to list
>comprehension discussion?
<snip>
>Eugene

I actually had something else in mind.  One problem that you get whenever
you extend a language 'i.e. make it more expressive' is that it now becomes
possible for people to write old things they want to do in new ways.  And,
of course, this is what you want for the case of <whatever you want the
more expressiveness for>, but it is difficult to may a syntax change that
doesn't admit a whole lot of other possibilities as well.

The argument I have heard around here is 'good programmers don't write
unreadable code, as a matter of personal virtue'.  This ignores the
fact that I have to read a lot of code written by either not-so-good
or not-so-virtuous programmers, but I am coming to the conclusion that
the problem may be deeper than that.  I now believe that some of the
hard-to-read stuff I am reading is written by people who actually find
this way of writing easier to read and understand than the sort I
prefer.

Thus I now think that 'expressiveness' is a limited human good, not an
absolute one, (like health).  You should want you language to be in the
golden middle between 'not epressive enough' and 'too expressive'.  If
your language is sufficiently limited, then idioms will show up, and
become widely adopted precisely because they are one of only a few ways
(ideally the only way) to do it.  This already pleases the people who 
find this way to do things readable, and those who would naturally pick
a different way of doing things are stuck with it, and possibly over time
and with familiarity will come to find this way readable as well. 

But with too much expressibility there comes a danger we will fragment into
different sub-communities, those who think that syntax X is more readable
than syntax Y and vice versa.  There is no reason to believe that these
linguistic communities will ever converge. This is the hidden cost of allowing 
more expressiveness in your language.

Laura





More information about the Python-ideas mailing list