[Python-Dev] Explicit Lexical Scoping (pre-PEP?) (original) (raw)
Fredrik Lundh fredrik at pythonware.com
Fri Jul 7 12:38:43 CEST 2006
- Previous message: [Python-Dev] Explicit Lexical Scoping (pre-PEP?)
- Next message: [Python-Dev] Explicit Lexical Scoping (pre-PEP?)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Just van Rossum wrote:
Why couldn't at least augmented assignment be implicitly rebinding? It has been suggested before (in the context of a rebinding operator), but I'm wondering, is this also off the table?
def counter(num): def inc(): num += 1 return num return inc Reads very natural to me. It's likely the most frequent example of what people try before they learn that rebinding to outer scopes isn't allowed. It could Just Work.
note that most examples of this type already work, if the target type is mutable, and implement the right operations:
def counter(num):
num = mutable_int(num)
def inc():
num += 1
return num
return inc
maybe we should consider adding mutable strings and mutable numbers to Python 3.0 ? and a "mutable" built-in, that does the opposite of the "freeze" stuff:
def counter(num):
num = mutable(num)
def inc():
num += 1
return num
return inc
(what is this thread doing on python-dev, btw? shouldn't it be over at the 3000 list, so I can enjoy my vacation without being drawn into yet another endless discussion thread ;-)
- Previous message: [Python-Dev] Explicit Lexical Scoping (pre-PEP?)
- Next message: [Python-Dev] Explicit Lexical Scoping (pre-PEP?)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]