Re: [Python-ideas] [Python-Dev] Tangent on class level scoping rules
Nick Coghlan wrote:
Dealing with references from nested closures is the hard part.
I think that could be handled by creating new cells for the inner variables each time the inner scope is entered. -- Greg
On 24 Feb 2014 07:46, "Greg Ewing" <greg.ewing@canterbury.ac.nz> wrote:
Nick Coghlan wrote:
Dealing with references from nested closures is the hard part.
I think that could be handled by creating new cells for the inner variables each time the inner scope is entered.
Yes, it's not hard * in theory*, it's just hard *in practice*, given the current design of CPython's compiler - my perspective is informed by trying to do it for comprehensions and eventually deciding "meh, I'll just use a real closure so they behave *exactly* like generator expressions in a constructor call and I can stop worrying about it". There's also the fact that even after getting it to work, you have to *document* it in the language reference as a new kind of scope, because it doesn't behave the same way as any of the existing ones. Sure, it only differs from a full closure in a few obscure edge cases, but it still differs. Cheers, Nick.
-- Greg _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
participants (2)
-
Greg Ewing -
Nick Coghlan