[Python-ideas] allow `lambda' to be spelled λ
steve at pearwood.info
Wed Jul 13 22:44:15 EDT 2016
On Wed, Jul 13, 2016 at 03:42:01PM -0500, Alexander Belopolsky wrote:
> On Wed, Jul 13, 2016 at 2:20 PM, Paul Moore <p.f.moore at gmail.com> wrote:
> > Um, as someone significantly older than 10 years old, I don't know how
> > to type a lambda character on my Windows UK keyboard...
> FWIW, in IPython/Jupyter notebooks one can type \lambda followed by a tab
> to get the λ character. The difficulty of typing is a red herring. Once
> it is a part of the language, every editor targeted at a Python programmer
> will provide the means to type λ
Great for those using an editor targeted at Python programmers, but most
editors are more general than that. Which means that programmers will
find themselves split into two camps: those who can easily type λ, and
those that cannot.
In the 1980s and 90s, I was a Macintosh user, and one nice feature of
the Macs at the time was the ease of typing non-ASCII characters. (Of
course there were a lot fewer back then: MacRoman is an 8-bit extention
to ASCII, compared to Unicode with its thousands of code points.)
Consequently I've used an Apple-specific language that included
operators like ≠ ≤ ≥ and it is *really nice*.
But Apple has the advantage of controlling the entire platform and they
could ensure that these characters could be input from any application
on any machine using exactly the same key sequence. (By memory, it was
option-= to get ≠.) We don't have that advantage, and frankly I think
you are underestimating the *practical* difficulties for input.
I recently discovered (by accident!) the Linux compose key. So now I
know how to enter µ at the keyboard: COMPOSE mu does the job. So maybe
COMPOSE lambda works? Nope. How about COMPOSE l or shift-l or ll or la
or yy (its an upside down y, right, and COMPOSE ee gives ə)?
No, none of these things work on my system. They may work on your system: since
discovering COMPOSE, I keep coming across people who state "oh, its easy
to type such-and-such a character, just type COMPOSE key-sequence, its
standard and will work on EVERY LINUX SYSTEM EVERYWHERE". Not a chance.
The key bindings for COMPOSE are anything but standard.
And COMPOSE is *really* hard to use well: it gives no feedback if you
make a mistake except to silently ignore your keypresses (or insert the
wrong character). So invariably, every time I want to enter a non-ASCII
character, it takes me out of "thinking about code" into "thinking about
how to enter characters", sometimes for minutes at a time as I hunt for
the character in "Character Map" or google for it on the Internet.
It may be reasonable to argue that code is read more than it is written:
- suppose that reading λ has a *tiny* benefit of 1% over "lambda"
(for those who have learned what it means);
- but typing it is (lets say) 50 times harder than typing "lambda";
- but we read code 50 times as often as we type it;
- so the total benefit (50*1.01 - 50) is positive.
Invent your own numbers, and you'll come up with your own results. I
don't think there's any *objective* way to decide this question. And
that's why I don't think that Python should take this step: let other
languages experiment with non-ASCII keywords first, or let people
experiment with translators that transform ≠ into != and λ into lambda.
More information about the Python-ideas