[Python-Dev] LOAD_NAME & classes

Tim Peters tim.one@comcast.net
Tue, 23 Apr 2002 12:43:21 -0400

> ...
> But Python *is* unique in that it doesn't require declarations.  (I've
> got to admit that the Perl example saddened me.  But then in Perl,
> local variables are a recent invention. :-)

Just FYI, "local()" in Perl is very old, and has always used dynamic scoping
rules.  If you don't wrap local() around a vrbl decl, you get a global vrbl
instead, and that's also very old.  What's relatively new is the "my()" vrbl
wrapper, which asks for a lexically scoped vrbl.  What's very new is
"our()", which I still haven't figured out:

    An "our" declares the listed variables to be valid globals within
    the enclosing block, file, or eval.  That is, it has the same scoping
    rules as a "my" declaration, but does not create a local variable.  If
    more than one value is listed, the list must be placed in parentheses.
    The our declaration has no semantic effect unless "use strict vars"
    is in effect, in which case it lets you use the declared global
    variable without qualifying it with a package name. (But only within
    the lexical scope of the our declaration. In this it differs from
    "use vars", which is package scoped.)

Anyone want to make a motion that we not ape Perl's scoping rules <wink>?