[Python-Dev] LOAD_NAME & classes

Scott Gilbert xscottg@yahoo.com
Wed, 24 Apr 2002 00:37:03 -0700 (PDT)

--- Tim Peters <tim.one@comcast.net> wrote:
> This is actually what happens in Icon, which also lacks declarations (in
> the same sense Python lacks them:  it doesn't lack them <wink>).  The
> difference
> is that all variables are global by default in Icon, and you need to
> explicitly say "local x" if you want a local var instead.  That's
> error-prone for sure, by not quite as much so as Perl (where x is also
> global by default, but "local $x" sucks you into dynamic scoping; it does
> not in Icon).

A few corrections.  New variable names were local by default.  The only way
to get a global variable was to make a "global varname" statement at the
global scope.  Icon gave you a None-like value, &null, for your variables
if you hadn't already assigned to them somewhere.  So strictly speaking,
you could read a variable before writing to it, and a declaration (first
initialization) wasn't necessary the same way it is in Python.

Using "local x" was strongly recommended because (a) you could use the -u
switch of icont to warn you when you didn't declare your locals (usually
from typos), and (b) in case you forgot that you used the same name as a
global somewhere else, or more likely you "link"ed with a file that had
global declarations you weren't aware of.

So it really wasn't so error prone.  (Icon's not even close to Perl in this
regard.  :-)


Do You Yahoo!?
Yahoo! Games - play chess, backgammon, pool and more