|
I have a lot more code using _G than hyperbolic trig. Possibly +inf times more.
Which can simply be circumvented if it wouldn't be there:local _G = _ENVlocal _ENV = setmetatable({}, {__index=_ENV})
function print(...)
_G.print("my print:", ...)
end
I agree with Dirk, _G ought to be deprecated.On Tue, Aug 12, 2014 at 12:51 PM, Tom N Harris <telliamed@whoopdedo.org> wrote:
I think it still has a place.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.
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>