lua-users home
lua-l archive

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

On 26 September 2011 11:31, steve donovan <> wrote:
> On Mon, Sep 26, 2011 at 12:05 PM, steve donovan
> <> wrote:
>> Assuming then that _ENV always exists as an upvalue, then _ENV.print
>> is an explicit way to access a 'global'.
> This is of course typical Monday morning nonsense; precisely because
> _ENV can be redefined. So _G is what I mean here.
> Except that in strict mode _G is an upvalue for any script, and any
> access to 'globals' has to go through it. So you have to say
> local print,io = _G.print,
> up front.  (The import suggestion is merely sugar for this pattern)
> steve d.

_G is normally an alais for _ENV is 5.2 or an alais for the value set
unless I am misunderstanding something and there are no global lookups
so to speak anymore (ie GETGLOBAL vm instructions now use a new
instruction GET/SETTABUP), so I still do not understand why
_ENV/_G.print would be needed unless there is a print in local scope.

Sorry maybe the Monday afternoon nonsense is the time it effects me :p