lua-users home
lua-l archive

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


On Mon, May 7, 2012 at 9:23 AM, Miles Bader <miles@gnu.org> wrote:
> E.g. a common use is to list all global variables:
>
>   for k,v in pairs(_G) do print (k, v) end

Or to make new global variables:

key = 'dog'
_G[key] = 'barney'

There's nothing magic about _G; the magic is that the 'global
environment' is _just a table_, and _G is a variable referencing it.

(_ENV is more subtle, since _setting it_ is meaningful)

steve d.