[Python-Dev] PEP for Better Control of Nested Lexical Scopes

Josiah Carlson jcarlson at uci.edu
Tue Feb 21 06:01:01 CET 2006


"Almann T. Goo" <almann.goo at gmail.com> wrote:
> I would like the community's opinion if there is enough out there that think
> this would be a worthwile endevour--or if there is already an initiative
> that I missed.  Please let me know your questions, comments.

-1

Mechanisms which rely on manipulating variables within closures or
nested scopes to function properly can be elegant, but I've not yet seen
one that *really* is. You state that using classes can be "heavy handed",
but one of the major uses of classes is as a *namespace*. Many desired
uses of closures (including the various uses you have outlined) is to
hide a *namespace*, and combining both closures with classes can offer
that to you, without requiring a language change.  Of course using
classes directly with a bit of work can offer you everything you want
from a closure, with all of the explcitness that you could ever want.


As an aside, you mention both 'use' and 'scope' as possible keyword
additions for various uses of nested scopes.  In my experience, when one
goes beyond 3 or so levels of nested scopes (methods of a class defined
within a class namespace, or perhaps methods of a class defined within a
method of a class), it starts getting to the point where the programmer
is trying to be too clever.

 - Josiah



More information about the Python-Dev mailing list