lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> I don't know the languages you know, but the languages I know don't behave
> like that. In C, for instance, if you write
>
>   void f (void) {
>     i = i+1;
>   }
>
> this `i' is not "automatically local". If you want a local `i', you must
> say so. The same is true in C++, Pascal, Java, Perl, Ada, FORTRAN, Scheme,
> Simula, Smalltalk, SNOBOL, ML, Haskell, etc. etc. (Tcl is one of the few
> exceptions.)
>

Python example:

>>> def f():
...     i = i+1
...
>>> i = 1
>>> f()
Traceback (innermost last):
  File "<stdin>", line 1, in ?
  File "<stdin>", line 2, in f
NameError: i
>>>

--

  Magnus Lie Hetland      (magnus at hetland dot org)

 "Reality is what refuses to disappear when you stop
  believing in it"                 -- Philip K. Dick