"Don't rebind built-in names*" - it confuses readers

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Jun 10 23:02:10 EDT 2013


On Mon, 10 Jun 2013 19:36:44 -0700, rusi wrote:

> Pascal introduced the idea of block structure -- introduce a name at one
> level, override it at a lower level. [Ok ALgol introduced, Pascal
> popularized].
> This has caused more trouble than it has solved.

I take it you have never programmed in a programming language with a 
single, flat, global namespace? :-)


> And so languages nowadays tend to 'protect' against this feature.

Apart from Erlang, got any other examples? Because it seems to me that in 
languages with nested scopes or namespaces, shadowing higher levels is 
exactly the right thing to do. Certainly it would be a PITA, and defeat 
the purpose of having nested scopes, if inner names had to be globally 
unique. Wouldn't it be absolutely horrible if adding a global variable 
"foo"[1] suddenly meant that all your functions that used "foo" as a 
local variable stopped working?




[1] For some value of "foo".


-- 
Steven



More information about the Python-list mailing list