"M.-A. Lemburg" wrote: > > Jeremy Hylton wrote: > > > > Looks like we need to rehash this thread at least enough to determine > > who is responsible for causing us to rehash it. > > > > MAL said it would break code. I asked how. Skip and Tim obliged with > > examples. I said their examples exhibited bad style; neither of them > > claimed they were good style. > > > > In the end, I observed that while it could break code in theory, I > > doubted it really would break much code. Furthermore, I believe that > > the code it will break is already obscure so we needn't worry about > > it. > > That's just what I was trying to say all along: statically > nested scopes don't buy you anything except maybe for lambdas > and nested functions (which is bad style programming, IMHO too). > > The only true argument for changing scoping I see is that > of gained purity in language design... without much practical > use. > > Other issues that need sorting out: > > x = 2 > class C: > x = 1 > C = 'some string' > def a(self): > print x > def b(self): > global x > x = 3 > > class D(C): > C = 'some string' > def a(self): > C.a(self) > print C > > o = C() > o.a() > o.b() > o.a() > > o = D() > o.a() > > What would the output look like under your proposal ? [Moshe pointed out to me in private mail that the above would continue to work as it does now due to a difference being made between class and function scoping categories] More questions: How are you going to explain the different scoping categories to a newbie ? What if you define a class within a method ? How can you explicitely attach a dynamically defined class to a certain scope ? More problems (?!): Nested scopes will introduce cycles in all frame objects. This means that with GC turned off, frame objects will live forever -- Python will eat up memory at a very fast pace. BTW, Python's GC only works for a few builtin types (frames are not among the supported types): what if a frame finds its way into a user defined type ? Will GC still be able to cleanup the cycles ? Perhaps I'm just being silly, but I still don't see the benefits of breaking todays easy-to-grasp three level scoping rules... -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/
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