[Python-ideas] A simple proposal concerning lambda
MRAB
python at mrabarnett.plus.com
Tue Aug 21 22:12:09 EDT 2018
On 2018-08-22 02:38, Elazar wrote:
> I don't think this change makes sense, but if it's done, there should be
> another change, with actual implications:
> There is no way to express the types of the parameters in a lambda -
> `lambda x: int : x` is obviously a syntax error. Replacing the colon
> with a different symbol, such as "=>" will make this possible:
>
> def x => x
> def x: int => x
> def x: int -> int => x
>
> It will also give one less meaning to the colon.
>
The examples I showed had parens, so your examples could be:
def (x): x
def (x: int): x
def (x: int) -> int: x
>
> On Tue, Aug 21, 2018 at 6:28 PM MRAB <python at mrabarnett.plus.com
> <mailto:python at mrabarnett.plus.com>> wrote:
>
> On 2018-08-22 01:25, Jonathan Fine wrote:
> > Hi Abe
> >
> > Summary: You've done good work here. I've skim read the 2006
> > discussion you found.
> >
> > You wrote:
> >
> >> I'm trying to dig up past threads about alternatives to lambda
> because I
> >> would be astonished if "def" hadn't been considered and rejected
> for some
> >> reason. What I've found so far is this unreassuring post from
> Guido back in
> >> 2006
> >
> >> [Python-Dev] Let's just *keep* lambda
> >>
> https://mail.python.org/pipermail/python-dev/2006-February/060415.html
> >
> > This is an excellent piece of work. I'm most grateful. Here's
> what Guido said:
> >
> >> After so many attempts to come up with an alternative for lambda,
> >> perhaps we should admit defeat. I've not had the time to follow the
> >> most recent rounds, but I propose that we keep lambda, so as to stop
> >> wasting everybody's talent and time on an impossible quest.
> >
> > I've quickly read through the posts that followed Guido's message,
> > picked out the ones that interest me. Here's a list.
> >
> >>
> https://mail.python.org/pipermail/python-dev/2006-February/060487.html
> >>
> https://mail.python.org/pipermail/python-dev/2006-February/060474.html
> >>
> https://mail.python.org/pipermail/python-dev/2006-February/060471.html
> >>
> https://mail.python.org/pipermail/python-dev/2006-February/060445.html
> >>
> https://mail.python.org/pipermail/python-dev/2006-February/060435.html
> >>
> https://mail.python.org/pipermail/python-dev/2006-February/060431.html
> >>
> https://mail.python.org/pipermail/python-dev/2006-February/060470.html
> >
> > And one of the messages had a link to still live and excellent page
> >
> >> https://wiki.python.org/moin/AlternateLambdaSyntax
> >
> > This page lists over 100 suggestions, mostly variants. So far as
> I can
> > see, my simple proposal isn't listed on that page. The page also says
> >
> Hmm.
>
> That lists:
>
> def (a, b, c): return f(a) + o(b) - o(c)
>
> and:
>
> def (a, b, c) = f(a) + o(b) - o(c)
>
> but not:
>
> def (a, b, c): f(a) + o(b) - o(c)
>
> >> **Definitely Desirable Features**
> > [snip]
> >> *More friendly to inexperienced users*
> > [snip]
> >> Compared to other Python keywords, 'lambda' is rather esoteric.
> >> In the challenge for "farthest outside day-to-day English usage",
> >> its closest competitor would probably be 'assert', as even 'def'
> >> and 'elif' are just abbreviations for 'define' and 'else if'. Use of
> >> simpler keywords may make deferred expressions appear less
> >> intimidating than they seem with the current unusual keyword.
> >
> > The word 'deferred' appears 7 times on the page. It also appears in
> > the python-dev messages.
> >
> > If someone with more time and less bias then myself were to summarise
> > this discussion from 2006, I'd be most grateful, and they'd have
> > material for a great blog post.
> >
> > Finally, many thanks to Abe for finding this gem, and countless
> > people's hard work in keeping it alive to be found. Backwards
> > compatibility is there for a reason.
> >
More information about the Python-ideas
mailing list