[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Why _ENV, not _G?
- From: steve donovan <steve.j.donovan@...>
- Date: Sun, 11 Jul 2010 17:15:04 +0200
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 ;)