On Wed, Dec 01, 2021 at 09:58:11PM -0600, Abe Dillon wrote:
> My favorite alternative is ?= if people think => and -> are getting
> overly loaded. What I really don't like is @param= because it puts the
> emphasis on the parameter name rather than the act of binding. Not only
> does it make it look like @param is a special kind of variable, it also
> mimics the *args and **kwargs syntax which makes them seem related.
But it *is* a special kind of parameter: it is a parameter that uses
late binding for the default value, instead of early binding.
Putting the emphasis on the parameter name is entirely appropriate.
Late bound parameters don't have a different sort of binding to other
parameters. There aren't two kinds of binding:
1. Parameters with no default, and parameters with early bound default,
use the same old type of name binding that other local variables use
(local slots in CPython, maybe a dict for other implementations);
2. and parameters with late bound defaults use a different sort of name
binding, and we need a different syntax to reflect that.
That is wrong: there is only one sort of binding in Python (although it
can have a few different storage mechanisms: slots, cells and dict
namespaces, maybe even others). The storage mechanism is irrelevant.
It's all just name binding, and the implementation details are handled
by the interpreter.
By the time the function body is entered, all the parameters have been
bound to a value. (If there are parameters that don't have a value, the
interpreter raises an exception and you never enter the function body.)
It doesn't matter where those values came from, whether they were passed
in by the caller, or early bound defaults loaded from the cache, or late
bound defaults freshly evaluated. The value is bound to the parameter in
exactly the same way, and you cannot determine where that value came
Python-ideas mailing list -- python...@python.org
To unsubscribe send an email to python-id...@python.org
Message archived at https://mail.python.org/archives/list/python...@python.org/message/LYRLA3TH47H4EKOR3NCIUZKXJOICJ5R7/
Code of Conduct: http://python.org/psf/codeofconduct/