[Python-Dev] statically nested scopes

M.-A. Lemburg mal@lemburg.com
Thu, 02 Nov 2000 13:12:42 +0100


Greg Ewing wrote:
> 
> "M.-A. Lemburg" <mal@lemburg.com>:
> 
> > The problem is that with nested scoping, a function defined
> > within another function will suddenly reference the variables
> > of the enclosing function
> 
> This could be avoided by requiring that variables which are
> to be visible in an inner scope be marked somehow in the
> scope where they are defined.
> 
> I don't think it's a serious enough problem to be worth
> fixing that way, though.

It may not look serious, but changing the Python lookup scheme
is, since many inspection tools rely and reimplement exactly
that scheme. With nested scopes, there would be next to no
way to emulate the lookups using these tools.

To be honest, I don't think static nested scopes buy us all that
much. You can do the same now, by using keyword arguments which
isn't all that nice, but works great and makes the scope clearly
visible.

Dynamic nested scopes is another topic... those are *very*
useful; especially when it comes to avoiding global variables
and implementing programs which work using control objects
instead of global function calls.

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/