[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Implicit Globals - A (better?) compile time solution.
- From: "John Hind" <john.hind@...>
- Date: Sat, 23 Feb 2008 12:54:06 -0000
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.