lua-users home
lua-l archive

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

On Thu, Feb 25, 2010 at 2:40 PM, Luiz Henrique de Figueiredo
<> wrote:
> They're not at all the same thing: changing _G has no effect, whereas
> changing _ENV does. _G is just the default value for _ENV in chunks
> loaded with load. More precisely, the default value is the table of
> globals, which happens to be the starting value of _G.

Under the proposed new system, it seems like _G becomes some
miscellaneous global variable with no apparent use:
1) Changing _G has no effect (or at least no useful effect, just like currently)
2) Reading from _G is redundant (cases where current code reads from
_G could almost all be replaced with reads from _ENV)
3) The top-level chunk can already grab the globals table from the
initial value of _ENV - it doesn't need a preset global variable in
order to grab the globals table.

Hence I would remove _G. Once _G is removed, the next obvious step is
to rename _ENV to _G in order to maintain as much compatibility as
possible with 5.1.