Also: I know there are several modern computer languages that use arrows to
represent anonymous functions (JS, Kotlin, Scala...).

I also personally remember using (and teaching) Maple in the mid-90s, which
used arrows to define functions:

https://www.maplesoft.com/support/help/Maple/view.aspx?path=operators/functional

I used to find it perfectly natural.

(There is obviously a fundamental difference here: Maple's functions are
symbolic, while Python's are procedural. Maple also has procedures which
can't be manipulated symbolically).

  S.


On Tue, Feb 23, 2021 at 10:57 AM Stéfane Fermigier <s...@fermigier.com> wrote:

> Hi,
>
> My personal opinion is that arrows or even fat arrows would be a nice
> addition to the Python language for anonymous functions.
>
> I cringe a bit every time I have to write "lambda x: ..." (and even more
> for parameter-less "lambda: ...").
>
> I have a background in math so I find arrow notation very natural. I have
> studied a bit lambda calculus, so I can relate to a notation inspired by it
> too, but I believe:
>
> 1) That for it to be elegant, it should be more concise e.g. "ƛx: .." not
> "lambda x: ..." (but Python is not APL and I don't believe we are ready to
> introduce non-ascii unicode notations in the language).
>
> 2) More importantly, I believe most people are more familiar with the
> arrow notation than the lambda notation (lambda calculus is, AFAIK, only
> taught in advanced logic or CS courses at the University).
>
>   S.
>
>
>
> On Tue, Feb 23, 2021 at 10:26 AM Steven D'Aprano <st...@pearwood.info>
> wrote:
>
>> On Mon, Feb 15, 2021 at 09:29:45AM -0800, Guido van Rossum wrote:
>>
>> > Proposals like this always baffle me. Python already has both anonymous
>> and
>> > named functions. They are spelled with 'lambda' and 'def', respectively.
>> > What good would it do us to create an alternate spelling for 'def'?
>> [...]
>>
>>
>> I think that the desire probably comes from thinking of short
>> mathematical functions where the body is a simple expression, like in
>> maths:
>>
>>     def f(x):
>>         return 3*(x**2) - 2*x + 4
>>
>> is kinda clunky and not very maths-like compared to:
>>
>>     f(x) -> 3*(x**2) - 2*x + 4
>>
>> which is suggestive of function notation:
>>
>>     f : ℝ -> ℝ, f(x) = 3*(x**2) - 2*x + 4
>>
>> If you've used modern Computer Algebra System calculators, they often
>> have similar notation:
>>
>>     # Texas Instruments Nspire
>>     3⋅x² − 2⋅x + 4 -> y
>>
>> (except they have a proper arrow too, not just ASCII hyphen greater
>> than).
>>
>> So there is definitely some aesthetic advantage to the arrow if you're
>> used to maths notation, and if Python had it, I'd use it.
>>
>> But it doesn't scale up to multi-statement functions, and doesn't bring
>> any new functionality into the language, so I'm not convinced that
>> its worth adding as a mere synonym for def or lambda or both.
>>
>>
>> --
>> Steve
>> _______________________________________________
>> 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/SIY32PZLEPFLRPHWHT5FI3LCJGBXNNTB/
>> Code of Conduct: http://python.org/psf/codeofconduct/
>>
>
>
> --
> Stefane Fermigier - http://fermigier.com/ - http://twitter.com/sfermigier
> - http://linkedin.com/in/sfermigier
> Founder & CEO, Abilian - Enterprise Social Software -
> http://www.abilian.com/
> Chairman, National Council for Free & Open Source Software (CNLL) -
> http://cnll.fr/
> Founder & Organiser, PyParis & PyData Paris - http://pyparis.org/ &
> http://pydata.fr/
>


-- 
Stefane Fermigier - http://fermigier.com/ - http://twitter.com/sfermigier -
http://linkedin.com/in/sfermigier
Founder & CEO, Abilian - Enterprise Social Software -
http://www.abilian.com/
Chairman, National Council for Free & Open Source Software (CNLL) -
http://cnll.fr/
Founder & Organiser, PyParis & PyData Paris - http://pyparis.org/ &
http://pydata.fr/
_______________________________________________
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/AQPMLTWBW6XTQCN6HUMXRNBMZVULEWZ7/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to