lua-users home
lua-l archive

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


Am 30.04.2013 01:24 schröbte Petite Abeille:

On Apr 30, 2013, at 12:47 AM, Philipp Janda <siffiejoe@gmx.net> wrote:

Am 29.04.2013 23:31 schröbte Petite Abeille:

But… _ENV is not the global environment... _G is.

To figure out which environment should be considered a "global" environment would require some convention like: only environments passed to one of the load* functions are global environments, or any environment that contains (most of) the Lua standard library is a global environment, or if there's a field _ENV._G that refers back to _ENV, then _ENV is considered a global environment.

Nah. _G is always at LUA_RIDX_GLOBALS. And that is that.

http://www.lua.org/manual/5.2/manual.html#2.2
http://www.lua.org/manual/5.2/manual.html#4.5

Do you mean the value that is *currently* at LUA_RIDX_GLOBALS, or the one that was there when the Lua state was created? Obviously this is a runtime thing (the registry only exists at runtime).

Anyway, this definition is not really useful for catching typos in Lua code, which is what the global checkers are mostly about ...


But all this can only be checked at runtime anyway:

Most likely yes.

R.I.P. byte code analyzes for globals in 5.2. Oh, well...


You will simply get some false alarms. The more you change _ENV the more false alarms you will get.

Philipp