lua-users home
lua-l archive

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


On Sun, Jul 11, 2010 at 5:04 PM, GrayFace <sergroj@mail.ru> wrote:
> _G is just a field of _ENV that can be set to anything. For example, _G is
> nil after calling 'module' function (and module function is exactly a case
> when distinct access to global environment may be needed). If someone writes
> his own modules system, it's up to him to define _G. So, IMO, _G can't be
> relied on in 5.1.

Quite right, _G is just a name for a field in the global table which
happens to initially refer to the global table. I tend to do this:

local _G = _G
module (...)

Trying to explain this to a newcomer is an interesting exercise ;)