[Python-Dev] Re: Dynamic nested scopes
Barry A. Warsaw
Thu, 2 Nov 2000 11:31:35 -0500 (EST)
>>>>> "MZ" == Moshe Zadka <firstname.lastname@example.org> writes:
MZ> If MAL means dynamic scoping (which I understood he does),
MZ> then this simply means:
MZ> when looking for a variable "foo", you first search for it in
MZ> the local namespace. If not there, the *caller's* namespace,
MZ> and so on. In the end, the caller is the __main__ module, and
MZ> if not found there, it is a NameError.
This is how Emacs Lisp behaves, and it's used all the time in ELisp
programs. On the one hand it's quite convenient for customizing the
behavior of functions. On the other hand, it can make documenting the
interface of functions quite difficult because all those dynamically
scoped variables are now part of the function's API.
It's interesting to note that many ELispers really hate dynamic
scoping and pine for a move toward lexical scoping. I'm not one of
I'm not as concerned about "fixing" nested functions because I hardly
ever use them, and rarely see them much in Python code. Fixing
lambdas would be nice, but since Guido considers lambdas themselves a
mistake, and given that lamda use /can/ be a performance hit in some
situations, does it make sense to change something as fundamental as
Python's scoping rules to fix this eddy of the language?