On Sun, 30 Jul 2000, Tim Peters wrote: > But I don't know why we're arguing about it. Nobody (AFAIK) has announced > plans to take refcounting out of CPython, but that you can't *rely* on > refcounting across Python implementations is ancient news (and a reality in > practice since JPython). Well, to bring this back to the original: I proposed a variant of lexical scoping where an inner function has only a weak reference to its surroundin environment, so that def f(x): def g(): return x return g f(1)() Would fail with "UnboundOuterVariable", but the more commonly used def f(x): return map(lambda i,x=x: i*x, range(10)) Would turn into def f(x): return map(lambda i: i*x, range(10)) And work. Guido seemed to want to simulate classes by closures <wink>, and I tried to convince him that a) Python has a perfectly good class mechanism <3000 wink> b) non-weak references would cause cycles, which would mean that the currently working code: def f(file): file = open(file) def g(x): print x g(file.read()) Would fail is called in a loop if GC is not called too often. lexical-scoping-is-too-powerful-for-its-own-good-ly y'rs, Z. -- Moshe Zadka <moshez@math.huji.ac.il> There is no IGLU cabal. http://advogato.org/person/moshez
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4