lua-users home
lua-l archive

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


On Tuesday, August 12, 2014 09:16:59 AM Dirk Laurie wrote:
> 2014-08-12 8:51 GMT+02:00 Mason Mackaman <masondeanm@aol.com>:
> > Also, so far it seems like _G is the equivalent Lua 5.2’s appendix.
> 
> Maybe, for the sake of conceptual integrity, it could be deprecated
> in Lua 5.3.

I think it still has a place.

    local _ENV = setmetatable({}, {__index=_ENV})

    function print(...)
      _G.print("my print:", ...)
    end

There are three general scopes that most sensible programs will concern 
themselves with: local, file (or module or class), and global. The first has 
the `local' keyword, the second has the _ENV upvalue, and the last has _G.

-- 
tom <telliamed@whoopdedo.org>