[Python-ideas] allow `lambda' to be spelled λ

Steven D'Aprano steve at pearwood.info
Wed Jul 13 00:00:26 EDT 2016


On Wed, Jul 13, 2016 at 11:04:19AM +0900, Stephen J. Turnbull wrote:

> There was extensive discussion about the issues surrounding the
> natural languages used by programmers in source documentation (eg,
> identifier choice and comments) at the time of PEP 263.  The mojibake
> (choice of charset) problem has largely improved since then, thanks to
> Unicode adoption, especially UTF-8.  But the "Tower of Babel" issue
> has not.  Fundamentally, it's like women's clothes (they wear them to
> impress, ie, communicate to, other women -- few men have the interest
> to understand what is impressive ;-): programming is about programmers
> communicating to other programmers.

With respect Stephen, that's codswallop :-)

It might be true that the average bogan[1] bloke or socially awkward 
geek (including myself) might not care about impressive clothes, but 
many men do dress to compete. The difference is more socio-economic: 
typically women dress to compete across most s-e groups, while men 
mostly do so only in the upper-middle and upper classes. And in the 
upper classes, competition tends to be more understated and subtle 
("good taste"), i.e. expensive Italian suits rather than hot pants.

Historically, it is usually men who dress like peacocks to impress 
socially, while women are comparatively restrained. The drab business 
suit of Anglo-American influence is no more representative of male 
clothing through the ages as is the Communist Chinese "Mao suit".

And as for programmers... the popularity of one-liners, the obfuscated C 
competition, code golf, "clever coding tricks" etc is rarely for the 
purposes of communication *about code*. Communication is taking place, 
but its about social status and cleverness. There's a very popular 
StackOverflow site dedicated to code golf, where you will see people 
have written their own custom languages specifically for writing terse 
code. Nobody expects these languages to be used by more than a handful 
of people. That's not their point.


> Maintaining the traditional
> spelling of keywords and operators is definitely useful for that
> purpose.

Okay, let's put aside the social uses of code-golfing and equivalent, 
and focus on quote-unquote "real code", where programmers care more 
about getting the job done and keeping it maintainable rather than 
competing with other programmers for status, jobs, avoiding being the 
sacrifical goat in the next round of stack-ranked layoffs, etc.

You're right of course that traditional spelling is useful, but perhaps 
not as much as you think. After all, one person's traditional spelling 
is another person's confusing notation and a third person's excessively 
verbose spelling. Not too many people like Cobol-like spelling:

add 1 to the_number

over "n += 1". So I think that arguments for keeping "traditional 
spelling" are mostly about familiarity. If we learned lambda calculus in 
high school, perhaps λ would be less exotic.

I think that there is a good argument to be made in favour of increasing 
the amount of mathematical notation used in code, but I would think that 
since a lot of my code is mathematical in nature. I can see that makes 
my code atypical.

Coming back to the specific change suggested here, λ as an alternative 
keyword for lambda, I have a minor and major objection:

The minor objection is that I think that λ is too useful a one-letter 
symbol to waste on a comparatively rare usage, anonymous functions. In 
mathematical code, I would prefer to keep λ for wavelength, or for the 
radioactive decay constant, rather than for anonymous functions.

The major objection is that I think its still too hard to expect the 
average programmer to be able to produce the λ symbol on demand. We 
don't all have a Greek keyboard :-)

I *don't* think that expecting programmers to learn λ is too difficult. 
It's no more difficult than the word "lambda", or that | means bitwise 
OR. Or for that matter, that * means multiplication. Yes, I've seen 
beginners stumped by that. (Sometimes we forget that * is not something 
you learn in maths class.)

So overall, I'm a -1 on this specific proposal.




[1] Non-Australians will probably recognise similar terms hoser, 
redneck, chav, gopnik, etc.

-- 
Steve


More information about the Python-ideas mailing list