On 2021-10-30 19:11, Chris Angelico wrote:
> I mean, here's another way to come at this. Suppose we have this
under
>the proposal (using some random syntax picked at random):
>
>def foo(a=1, b="two", c@=len(b), d@=a+c):
>
> You keep saying that c and d "are argument default" just like a and b.
> So can you tell me what the argument default for each of those arguments?
The default for a is the integer 1. The default for b is the string
"two". The default for c is the length of b. The default for d is the
sum of a and c.
> The default for argument a is an integer. The default for argument b
>is a string. Can you tell me, in comparable terms, what the defaults
>for arguments c and d are?
You're assuming that every default is a*default value*. That is the
current situation, but it is by no means the only logical way a
default can be defined. See above: c's default is the length of b,
which is presumably an integer, and d's default is the sum of that and
a, which is probably also an integer (unless a is passed as a float or
something).
Well, at least that clarifies matters. :-)
I was already -1 on this but this moves me to a firm -100.
"The length of b" is a description in English, not any kind of
programming construct. "The length of b" has no meaning in Python.
What we store for the default (even if we don't want to call it a value)
has to be a Python construct, not a human-language description. I could
say "the default of b is the notion of human frailty poured into golden
goblet", and that would be just as valid as "the length of b" as a
description and just as meaningless in terms of
Python's data model.
The default of every argument should be a first-class value. That's
how things are now, and I think that's a very useful invariant to have.
If we want to break it we need a lot more justification than "I don't
like typing if x is None".
Apart from all the other things about this proposal I don't support, I
don't support the creation of a mysterious "expression" which is not a
first class value and cannot be used or evaluated in any way except
automatically in the context of calling a function.
--
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is no
path, and leave a trail."
--author unknown
_______________________________________________
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/HFRZ3Y7VCBRH7SIDFT563ZPVLMYEL5QU/
Code of Conduct: http://python.org/psf/codeofconduct/