In defence of the two-namespace rule
Tim Peters
tim_one at email.msn.com
Fri Jan 21 04:38:17 EST 2000
More information about the Python-list mailing list
Fri Jan 21 04:38:17 EST 2000
- Previous message (by thread): In defence of the two-namespace rule
- Next message (by thread): In defence of the two-namespace rule
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[Bernhard Herzog] > ... > However, several people have proposed lexical scoping > extensions and some of these proposals have even been > implemented. Lexical scoping is somewaht controversial > and I don't know what Guido's opinion is, although if the > technical reasons (cyclic references) Tim mentioned in > his post were the only reason Guido dropped it, it seems > likely that lexical scoping might be implemented if the > technical problems can be solved. I have a hard time distinguishing Guido's opinion from mine, but *some* bad days he does too so it's OK <wink>. FWIW, as a long-time Lisp and functional language fan, I harassed Guido about the lack of lexical scoping before Python 1.0 was released. He simply wanted to *try* a simpler name resolution scheme, and prevailed upon me to just give it a chance; in part, I believe he was unhappy with the extreme abuse of deep nesting common in Pascal programs of that time (I know I was <0.4 wink>), which often made large Pascal programs impossible to understand. So I tried it his stupid way, and damned if I didn't come to like it a whole lot -- the combo of flexible modules and flexible classes flatly <wink> proved much more satisfying to me as soon as I got the hang of it. So for several years Guido & I took turns arguing against "deep" lexical scoping on the Python mailing list, and, later, c.l.py. But not often! It just didn't come up much. And then "lambda" was introduced. The combo of lambda and "two-level" scoping basically sucks, and there's been a scoping roast ever since. It's never going to go away by itself, so one of the two has to bend. I still like Python's scoping rules, and am now so used to default-arg abuse (to leak names across the scope boundary) that I'm barely conscious of its strangeness anymore. It clearly isn't a real problem for Guido either. But it was and remains unboundedly surprising to newcomers, and that's un-Pythonic too. Guido has since said publically that he may have overreacted to "Pascal abuse", but that's the closest he's come (that I've heard, anyway) to saying he now likes traditional lexical scoping. On the basis of "if the implementation is easy to explain, it may be a good idea", he tried implementing it. As several people have been surprised to discover, lexical closures are laughably easy to add to Python -- frames are already heap allocated, and it's mostly just a matter of adding a "static link" for name resolution. So that's my guess on Guido's current opinion: while he still doesn't *like* closures, he's no longer deeply opposed to adding them; sees that the current combo of features is harmfully confusing to newcomers; and has to acknowledge that the simplicity of the required changes argues for an inherent naturalness. But, as I said, I have a hard time distinguishing Guido's opinion from mine <wink>. What I worry about (unsure about Guido on this one) is that adding closures will also intensify clamoring for more Lispish features. While I love them in their native languages, they grate against Python's approach, and every such addition to date has (in my arrogant opinion) done more harm to Python than good. List comprehensions are an exception: they'll work out great. To know the reason why, just ask a Scheme fanatic why Haskell is a terrible language <wink>. it's-not-for-lack-of-lambdas-ly y'rs - tim
- Previous message (by thread): In defence of the two-namespace rule
- Next message (by thread): In defence of the two-namespace rule
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list