map/filter/reduce/lambda opinions and background unscientific mini-survey

Steven D'Aprano steve at REMOVETHIScyber.com.au
Tue Jul 5 09:17:45 EDT 2005


On Tue, 05 Jul 2005 05:03:32 -0700, mcherm wrote:

> Steven D'Aprano writes:
>> Lambda is no more an obscure name than "function", "decorator", "closure",
>> "class", or "module". The first time you come across it, you don't know
>> what it means. Then you learn what it means, and then you know.
> 
> I believe you've made two errors here. First of all, "lambda" is part
> of the Python language, while "function", "decorator", "closure", and
> "module" are not. 

Sorry, but you are mistaken. "lambda" is a _reserved_ word in the
Python language, while "function" etc are not, but they are certainly
part of the language. Try explaining what def and import do without
using the words "function" or "module". Maybe you can do it, using
circumlocutions, but it isn't easy, and costs clarity.

[snip]
> The second error is that I believe most english speakers COULD provide
> a definition for the fairly common words "function", "class", and
> "decorator". The exact meaning of "class" might not be what they expect
> at first, 

Function, in the sense of a mathematical function, I agree. Class as in
the thing you go to at school and decorator as in the person who advises
you what colour curtains to have, certainly. But in the Python sense? No.
Especially not decorator, which I believe most _programmers_ would have
trouble explaining, let alone non-programmer English speakers. I know I do.


> but exposure to any object oriented language would make the
> concept quickly familiar. 

Just as exposure to functional languages would make lambda very familiar.

> But "lambda" has a very clear meaning... it's
> a letter of the greek alphabet. The connection between that letter and
> anonymous functions is tenuous at best, and fails the test of making
> Python read like "executable pseudocode".

Think back to when you were a schoolboy at your first day of school.
Unless you had a very unusual upbringing, you probably had never heard the
word "function" before. There is nothing about the word "function" that
brings to mind "a mathematical entity which transforms a variable into a
different variable", let alone "a programming subroutine that returns a
result". (Or for that matter, "the purpose which a person or thing is
for", as in the function of a spanner is to tighten nuts on bolts.)

You had to learn that word, discover what it means, and then it becomes
familiar. You don't notice the process only because it happened so long
ago, at an age that your brain was operating in "language acquisition
mode" and picking up vocabulary at an incredible rate.

There is nothing about the word "string" that especially brings to mind
"an array of bytes representing characters". The analogy of "string of
characters" to "string of beads" breaks down as soon as you have multiple
lines of text. And as for float, that's what boats do, heaven only knows
what it has to do with numbers.

(Yes, I know what it has to do with numbers. But that is something I had
to learn, and even now I still have difficulty because I expect floats to
operate like mathematical real numbers, and they don't.)

And dare I say it, what do constricting snakes have to do with programming?

I won't say that the anonymous function meaning of lambda comes to my mind
before the Greek letter, but it isn't very far behind, and rapidly
catching up. (I use lambda a lot more than I speak Greek.) It wouldn't
surprise me if one day I think of Python programming before the Greek
letter, just as the world aleph brings to my mind the sense of infinity
before the sense of it being a Hebrew letter.


-- 
Steven.




More information about the Python-list mailing list