lua-users home
lua-l archive

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

Mark Hamburg wrote:
In an interactive environment, you want explicit globals because you are
likely to execute code a little bit at a time.

When compiling scripts, they are less desirable and globals are frequently a
performance lose. But note that anything that relies on something like "_G"
is depending on an implicit global.

Given that interactive line-by-line execution is probably a minority
interest, this argues for allowing global-by-default to be set in the "C"
API when a chunk is compiled, not for inflicting it on everyone by default!

I did not suggest that you should not be able to *access* globals
implicitly, only that you should not be allowed to *assign* to them
implicitly. So "_G" and all other global variables would continue to work as
at present. You should never need to assign to a library field, but if you
do, you still can - you just have to think about it!

One of the problems with sorting this out ourselves is that there is no way
to distinguish between implicit and explicit invocations of _newindex. If
_newindex received some kind of flag we could do better.