
On Wed, Oct 27, 2021 at 4:51 AM David Mertz, Ph.D. <david.mertz@gmail.com> wrote:
On Tue, Oct 26, 2021, 1:08 PM Chris Angelico <rosuav@gmail.com> wrote:
No, I agree. We have to still be able to introspect them.
At the moment, when you look at a function's defaults, they are all values. With this change, some would be values and some would be markers saying that code would be executed.
So why on earth NOT make these general "deferred" objects that can be used in other contexts?!
Because they're NOT deferred objects. They're argument defaults. Consider: def f(x=>print("Hello")): ... When should that print happen? Argument defaults are processed before the function body begins, so you can be confident that it has happened before the first line of actual code. But a deferred object might not be evaluated until later, and in fact might not be evaluated at all. Deferred evaluation is a useful feature, but that isn't what I'm proposing here. If you want to propose it as a completely separate feature, and then posit that it makes PEP 671 unnecessary, then go ahead; that's your proposal, not mine. ChrisA