PEP 312 - Making lambdas implicit worries me, surely it's just the name 'lambda' that is bad...

Stephen Horne intentionally at blank.co.uk
Mon Mar 3 16:13:33 EST 2003


On 03 Mar 2003 15:10:20 +0000, Alexander Schmolck <a.schmolck at gmx.net>
wrote:

>Do you think adding a few keystrokes by replacing
>
> >>> a + b * c[2]   
>
>with the more explict
>
> >>> a operatorAddOrMaybeConcatenate (b operatorMultiplyOrMaybeRepeat  c 
> ...                                    operatorAtIndexOrMaybeKey 1)
>
>would make python unusable? Or maybe just unpopular? 

Unpopular, of course. But then it's a bad comparison. The '+' and '*'
symbols are sufficiently familiar to even newbie programmers that they
are as explicit as is needed anyway. In fact your versions are less
explicit as they are less understandable to non-English-speakers.

There'll probably come a day when '*' is seen as a historic absurdity,
of course - a relic of the ASCII character set ;-)

Even more important than the familiarity of the '+' and '*' operators
is the fact that those symbols are only used for a small number of
purposes - essentially one purpose each, in fact, if you consider that
most people think of concatenating sequences as adding them, and
repeating sequences as multiplying them (hence the choice of symbols).

Finally, an excess of symbol-only syntax in any language is a bad
thing because it increases the odds of a person being confused by two
or more constructs in a single chunk of code and perhaps not even
being able to isolate one from the other - ie leaving the person with
a major headache figuring out what's happening. Instead of learning
the language incrementally, newbies have to know everything just to
read one line of code.

An implicit lambda is distinguished from a plain subexpression purely
by the presence of a colon. Colons are used for quite a few other
purposes. A symbols-only spelling of lambda would not necessarily be a
bad thing, but any syntax would have to be clearly distinct from other
syntactic forms. The fact that the PEP already lists cases where the
grammar cannot accomodate implicit lambdas due to ambiguities already
hints at how confusable this notation would be.

I agree that spelling is important, but the spelling in the PEP is
not, IMO, a good one.

-- 
steve at ninereeds dot fsnet dot co dot uk




More information about the Python-list mailing list