lua-users home
lua-l archive

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



On Sun, Jul 11, 2010 at 1:41 PM, GrayFace<sergroj@mail.ru>  wrote:
IMO, after _ENV is introduced, the old _G is redundant. _ENV supersedes it.
So, won't it be better to keep the name _G instead of _ENV? It's shorter.
But, it's different. _G always refers to global scope, _ENV refers to
current 'environment'. So it would be confusing to change the meaning
of _G.

_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.

--
Best regards,
Sergey Rozhenko                 mailto:sergroj@mail.ru