On Mon, Feb 15, 2021 at 9:02 AM Ricky Teachey <ricky@teachey.org> wrote:
[...]
But if we could expand the  proposal to allow both anonymous and named functions, that would seem like a fantastic idea to me.  

Anonymous function syntax:

(x,y)->x+y

Named function syntax:

f(x,y)->x+y

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 know that in JavaScript there are different ways to define functions ('function' and '=>'), and they have subtly different semantics. (For example, regarding 'this'. Such an incredible mess!) We don't need different semantics in Python.

I can sympathize with trying to get a replacement for lambda, because many other languages have jumped on the arrow bandwagon, and few Python first-time programmers have enough of a CS background to recognize the significance of the word lambda. But named functions? Why??
 
But since Guido wants to save the right shaft operator for type hinting, and named functions do need a way to write type hints, maybe the best thing to do is use an equal sign shaft for the function definition and the right shaft for the type hint:

f(x,y)=>x,y->str

>>> f('a','b')
'ab'
>>> f(1,2)  # type hint error

Another thing. Type hints are not interpreted at runtime, and I don't expect this to change in the near to middle future.

Plus, that syntax really has nothing to recommend it.

--
--Guido van Rossum (python.org/~guido)