
On Sat, 18 Jun 2022 at 13:13, Brendan Barnwell <brenbarn@brenbarn.net> wrote:
On 2022-06-17 14:23, Chris Angelico wrote:
I've just pushed a change to the wording. Let's see if it makes a difference.
I think the PEP would benefit from a fully explicit definition of exactly when and how the late-bound defaults would be evaluated. For instance, by demonstrating an "unrolling" into something paralleling existing Python code. Like:
def f(a=>items[0], items=[]): # body
is equivalent to:
def f(a=FakeDefault, items=[]): a = items[0] # body
That IS in the PEP. Have you read it?
I read it before your update. Is the version up now the updated one? I'm guessing it is, because of the remark about "implementations may choose to do this in two separate passes".
But I don't see where something like what I showed there is given as a specification. I do see the "How to Teach This" section, which has an example similar to mine. But that pretty clearly isn't specifying the behavior. It still talks about "broadly equivalent" and a "rule of thumb", which are more ways of saying things other than a fully explicit and normative specification of the behavior.
"Broadly equivalent" is the best you're going to get, though. The entire point of this proposal is that it isn't possible to do a perfect job without language support. So the best you'll get is something with a lot of caveats, or something that is just "basically like this". And your example has the exact same limitations. There's no "FakeDefault" that can behave like that. Is "broadly equivalent" such a bad thing? ChrisA