![](https://secure.gravatar.com/avatar/d67ab5d94c2fed8ab6b727b62dc1b213.jpg?s=120&d=mm&r=g)
On Sun, Oct 31, 2021 at 11:47 PM Eric V. Smith <eric@trueblade.com> wrote:
On 10/30/2021 10:08 PM, Christopher Barker wrote:
I'm a bit confused as to why folks are making pronouncements about their support for this PEP before it's even finished, but, oh well. I think it's safe to say people are opposed to the PEP as it current stands, not in it's final, as yet unseen, shape. But I'm willing to use other words that "I'm -1 on PEP 671". You can read my opposition as "as it currently stands, I'm -1 on PEP 671". As for what seems like one major issue:
Yes, this is a kind of "deferred" evaluation, but it is not a general purpose one, and that, I think, is the strength of the proposal, it's small and specific, and, most importantly, the scope in which the expression will be evaluated is clear and simple.
And to me and others, what you see as a strength, and seem opposed to changing, we see as a fatal flaw.
What if the walrus operator could only be used in "for" loops? What if f-strings were only available in function parameters? What if decorators could only be used on free-standing functions, but not on object methods?
In all of these cases, what could be a general-purpose tool would have been restricted to one specific context. That would make the language more confusing to learn. I feel you're proposing the same sort of thing with late-bound function argument defaults. And I think it's a mistake.
Deferred expressions are not the same as late-bound argument defaults. What is the correct behaviour here? def foo(a=>[1,2,3], b=>len(a)): a.append(4) print(b) And what is the correct behaviour here? def foo(a=defer [1,2,3], b=defer len(a)): a.append(4) print(b) When is 'a' evaluated and the list constructed? When is the length calculated and stored in 'b'? With argument defaults, it's clear: this happens as the function is called. (See other thread for a subtlety about whether this happens during frame construction or as the function-proper begins execution, but that is a minor distinction that doesn't affect non-generators very much.) With deferreds, the usual expectation is that they are evaluated on usage, which could be a very different point. Late-bound defaults are NOT "deferreds but limited to function headers". They are quite different. You can think of them as a sort of deferred expression if that helps, but they're not a specialization of a more general feature. ChrisA