
On 18/06/2022 15:51, Stephen J. Turnbull wrote:
This raises another choice: should lazy defaults be evaluated before entering the body of the function, or at the point where the parameter is used? Which would be more useful?
<img src=both_both_both.gif/>
Both are potentially useful. Yes, both *ARE* potentially useful. *ABSOLUTELY*. I don't think anyone would deny that. Certainly not I. Let's call "I want late-bound defaults and Python doesn't have them" Problem A. Let's call "I want my default value not to be evaluated until needed" Problem B. (Of course, you may not consider either to be a problem, but let's assume that you think that at least one of them is.) Chris is offering a PEP and an implementation which addresses Problem A. If Problem B is a problem for you, you can (currently) use a sentinel value, and explicitly evaluate the default when you want it. Not so terrible. In fact arguably, more often than not, better, because it's explicit. And more flexible (you can evaluate a different expression, or in a different scope, in different places in the function body). Chris/PEP 671 is not attempting to provide a better way of doing that. He is not offering Deferred Evaluation Objects (DEOs). Maybe in 5 years or so someone will offer an implementation of that, and everyone can be happy. 😁 Meanwhile, *Chris is offering a solution of Problem A*. He is *NOT addressing Problem B* - someone else is welcome to try that. Let's be honest: PEP 671 does not allow you to do anything you can't already. What is adds is some more convenience, some more concision, and arguably (and I *would* argue, in appropriate cases) some more readability.
Why do people keep obscuring the discussion of a PEP which addresses Problem A by throwing in discussion of the (unrelated) Problem B? (Chris, and I, have stated, ad nauseam, that these *are* unrelated problems. If you don't agree, I can only ask you to consider the implementations necessary to solve each. If that doesn't change your mind, I have to throw my hands in the air and say "We'll have to agree to differ".) *Surely solving one "problem" is better than dithering about which "problem" to solve.* I've been accused of trying to censor this thread, but really - I'm just frustrated when people are invited to comment on PEP 671, and they don't comment on PEP 671, but on something else. BTW Thank you Stephen Turnbull, for your measured comments to this thread. Best wishes Rob Cliffe