lua-users home
lua-l archive

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


On Mon, Sep 26, 2011 at 12:05 PM, steve donovan
<steve.j.donovan@gmail.com> 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, _G.io

up front.  (The import suggestion is merely sugar for this pattern)

steve d.