On Wed, Dec 01, 2021 at 10:50:38PM -0800, Brendan Barnwell wrote:
4) If "no" to question 1, is there some other spelling or other small change that WOULD mean you would use it? (Some examples in the PEP.)
No. As I mentioned in the earlier thread, I don't support any proposal in which an argument can "have a default" but that default is not a first-class Python object of some sort.
I don't understand this criticism. Of course the default value will be a first-class Python object of some sort. *Every* value in Python is a first-class object. There are no machine values or unboxed values, and this proposal will not change that. All that this proposal changes is *when* and *how often* the default will be evaluated, not the nature of the value. Status quo: default values are evaluated once, when the def statement is executed. With optional late-binding: default values are evaluated as often as they are needed, when the function is called. But the value will still be an object. I suppose that there will be one other change, relating to introspection of the function. You will no longer be able to inspect the function and see the default values as constants in a cache: >>> (lambda x=1.25: None).__defaults__ (1.25,) Depending on the implementation, you *might* be able to inspect the function and see the default expression as some sort of callable function, or evaluatable code object. (That would be nice.) Or even as a plain old string. All of which are first-class objects. Or it might be that the default expression will be compiled into the body of the function, where is it effectively invisible. So I guess that's a third change: when, how often, and the difference to introspection. -- Steve