> On 4 Dec 2021, at 09:44, Steven D'Aprano <st...@pearwood.info> wrote:
> 
> On Sat, Dec 04, 2021 at 03:14:46PM +1100, Chris Angelico wrote:
> 
>> Lots and lots and lots of potential problems. Consider:
>> 
>> def f():
>>    a = 1
>>    def f(b, x=>a+b):
>>        def g(): return x, a, b
>> 
>> Both a and b are closure variables - one because it comes from an
>> outer scope, one because it's used in an inner scope. So to evaluate
>> a+b, you have to look up an existing closure cell, AND construct a new
>> closure cell.
>> 
>> The only way to do that is for the compiled code of a+b to exist
>> entirely within the context of f's code object.
> 
> I dispute that is the only way. Let's do a thought experiment.

There are many possible implementation of the late bound idea that could create 
an object/default expression.
But is it reasonable to bother with that added complexity/maintenance burden 
for a first implementation.
And maybe no one will care enough to ever implement the ability to modify the 
code of a late bound
variables expression as a separate object later.

I think I understand the argument as being along the lines of
for early bound defaults they can be inspected and modified.
Therefore being able to do the same for late bound defaults must be implemented.

I'm not convinced that that is reasonable to require is implemented.

If python had always had late bound defaults, as it is with most languages in 
the survey
posted earlier in this thread, would that have been implemented as an 
object/expression?
Maybe, but I doubt it.

Summary: I agree it's not impossible, I do not agree that it's needed.

Barry

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/2GSTDHBKU55ZWUPVVGWRL44EYV54KFLV/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to