The _ENV table and the _G table

  • _ENV is associated with a chunk (a file)
  • _G is associated with the global environment of the program
    • _G is built as the program is loaded
  • _ENV in Lua 5.2 can be overridden by a local _ENV

a = 1 b = 2 local _ENV = {print = print, _G = _G} c = 5 d = 7 print(_G.a) print(_ENV.c)