On 27/10/2021 00:26, Christopher Barker wrote:
I'm very confused about the apparent convergence on the token "=>" for
deferred parameter assignment.
1) As others have said, it sure feels like the arrow is going the
wrong way.
But the bigger question I have is with the similarity to lambda:
2) As I understand it, there's a good chance that "=>" will be adopted
to mean defining an anonymous function, i.e. a new spelling of lambda.
But we can use lambda as default arguments (indeed, that's a common
idiom), and, presumably, lambda will be able to use deferred defaults.
So there's a reasonable probability that the same token will be used
in the same context, meaning two different things, maybe even at the
same time.
I'm sure the parser will be able to figure it out, but I really don't
get why folks think this is a good idea for human readability.
Can someone explain?
On the other hand, others have suggested :=, which is could also be
used as part of the expression, so not a good idea either :-(
There's no necessary clash. At present you can write
f(a = (b:=c)):
so you would be able to write
f(a:= (b:= c)):
Perhaps a tad confusing at first glance, but unambiguous.
BTW: was it intentional that this:
In [8]: def fun(x, y=(z:=3)):
...: print(x,y,z)
...:
...:
adds z to the function namespace -- sure seems odd to me.
In [9]: fun(2)
2 3 3
Erm, where else should z go? What would be the point of writing it if
it didn't?
Rob Cliffe
-CHB
--
Christopher Barker, PhD (Chris)
Python Language Consulting
- Teaching
- Scientific Software Development
- Desktop GUI and Web Development
- wxPython, numpy, scipy, Cython
_______________________________________________
Python-ideas mailing list [email protected]
To unsubscribe send an email [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived
athttps://mail.python.org/archives/list/[email protected]/message/XHXGW2LCCWUF3FLWBMBH2HVKQXBUYJAH/
Code of Conduct:http://python.org/psf/codeofconduct/
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/SL652RVSUB5YYPO7CYLN3F2JCLUNGNML/
Code of Conduct: http://python.org/psf/codeofconduct/