lua-users home
lua-l archive

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


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.
But all this can only be checked at runtime anyway:

    if "y" == io.read() then
      _ENV = { print = print }
    end
    print( "hello" )  --> global access or not?


Philipp