[Python-ideas] Does jargon make learning more difficult?
Steven D'Aprano
steve at pearwood.info
Tue Aug 21 10:31:21 EDT 2018
On Tue, Aug 21, 2018 at 02:07:33PM +0900, Stephen J. Turnbull wrote:
> I was an economist then, and I'm an economist still, but I met lambda
> in 1977. Surely lambda has had that role in computer languages since
> shortly before I was born. I would guess anybody above a certain age
> would reach for "lambda" first for a keyword to denote or define an
> anonymous function. Not because of the lambda calculus, but because
> of Lisp. (OK, that's indirectly because of the lambda calculus.)
Its pretty much a term of art.
(Aside: "term of art" is itself a term of art:
https://legal-dictionary.thefreedictionary.com/Term+of+Art )
I think that complaining about lambda is like complaining about "3-sigma
versus 6-sigma processes" in process management. (Not computer
processes, manufacturing processes and quality control.) Or for that
matter, "mean" and "standard deviation" in statistics.
The main difference is that most people are introduced to mean and stdev
in secondary school, while functional programming idioms and lambda are
generally stumbled across in the field. (I know that's how I learned of
the term: through Python.)
> Had Guido decided to change it to "def", I suspect he'd be regretting
> it slightly today, for reasons similar to the regrets about "range":
> we normally only allow omitting positional arguments at the end of the
> list. Maybe there's a better word than "regret". After all, It's
> hard to see how you could prototype range better than "range([START,]
> END, [STRIDE])", and the same might be true for "def [NAME] ([ARG0,]
> ...):".
Secure in the knowledge that Guido probably isn't reading this and won't
contradict me *wink* I'm going to try channelling him. I think he would
regret "def expressions", but not because of the range reason. I think
its because he likes the relatively strict demarcation between
statements and expressions.
We have 4 statements that have a expression form:
if...else versus ternary if expressions;
for loops versus comprehensions;
(soon) = assignment versus := assignment expressions; and
def versus lambda.
(Did I miss any? I don't include technicalities like dot attribute
access versus getattr and similar.) It's notable that in none of those
cases the syntax is quite the same in the two forms. There's always
enough differentiation between the statement and expression that there's
never any ambiguity which is intended. We don't have:
result = if condition expression else expression
where it is the lack of colons which hints that it is an expression, we
have a completely different syntax. So I think Guido probably wouldn't
like the idea of using def in expressions:
def function(arg, callback=def: None):
pass
That's my guess, for what it's worth.
--
Steve
More information about the Python-ideas
mailing list