On 2021-02-12 03:18, Chris Angelico wrote:
On Fri, Feb 12, 2021 at 7:57 PM Brendan Barnwell <brenb...@brenbarn.net> wrote:
On 2021-02-11 03:24, J. Pic wrote:
> Hi all,
>
> Lambdas can be defined as such:
>
> w = lambda: [12]
> x = lambda y: len(y)
>
> I'd like to propose the following:
>
> w = (): [12]
> x = (y): len(y)
>
> Or even another contraction for when there are no arguments:
>
> w =: [12]
I don't see any need for this. It's even more cryptic than "lambda"
because at least lambda is a word you can look up. This is just
inscrutable punctuation. Using different punctuation like "=>" doesn't
help.
sigh. That argument again?
I just asked Google about "javascript =>" and got a bunch of perfectly
good results. Some said "arrow function", others have "=>" in the
title:
https://stackoverflow.com/questions/24900875/whats-the-meaning-of-an-arrow-formed-from-equals-greater-than-in-javas
Yes, you CAN search for punctuation. Please can this argument die?
Okay, fine, drop that argument. It doesn't matter. The point is that
we currently have a way to write anonymous functions and this proposal
adds NO BENEFIT WHATSOEVER except that instead of typing "lambda" you
type two parentheses, thus saving you a grand total of two keystrokes
(you need to hit shift to get the parentheses, but not to type "lambda")
to get something that doesn't look any less cryptic.
Also the fact that JavaScript does something is evidence that it's
probably not a good idea. :-)
I just don't understand what makes people think that "(a, b): a+b" or
"(a, b) => a+b" or any of these other variants has any advantage at all
over "lambda a, b: a+b". Yes, "lambda" is cryptic and mysterious, but
so are all these alternatives. They don't solve any problems or allow
anything that wasn't already possible and they would just clutter up the
language.
--
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is no
path, and leave a trail."
--author unknown
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/FUFLAMURF3T27TS3DMUF2NFN4XCYEYOJ/
Code of Conduct: http://python.org/psf/codeofconduct/