Closed hikari-no-yume closed 9 years ago
Note: the interpreter and specification are currently in conflict here. The interpreter forbids shadowing, while the specification requires it!
After reading Guido van Rossum's excellent post on Python's True, False and None and how they are literals, not variables, I remember why shadowing is good. If you forbid it, you're making all new stdlib additions into reserved words, and that's awful for backwards-compatibility. So, shadowing shall be allowed.
Oops, I forgot that the interpreter actually did allow shadowing. My memory was bad. Anyway, the issue is resolved!
i.e., is the following valid, or not?
def
definitely won't allow redefinition of a variable within a scope. But within a new scope, can a variable be created with the same name as a scope lower in the stack, thus shadowing it?Not allowing shadowing would make the compiler's job easier, since you then couldn't, say, change the meaning of
def
.