[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to print the content of Table/
 
- From: Mark Hamburg <mhamburg.ml@...>
 
- Date: Tue, 8 May 2012 08:35:00 -0700
 
If you use some form of linter to check for inadvertent global assignments, _G can be the way to explicitly assign a global. Of course, if you also wrap your globals table in metatable logic to catch assignments, then you need to do rawset( _G, "var", value ).
Mark
On May 7, 2012, at 12:34 AM, steve donovan <steve.j.donovan@gmail.com> wrote:
> 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.
> 
- References:
- How to print the content of Table/, Emeka
 
- Re: How to print the content of Table/, Petite Abeille
 
- Re: How to print the content of Table/, Hallison Batista
 
- Re: How to print the content of Table/, Alexander Gladysh
 
- Re: How to print the content of Table/, Hallison Batista
 
- Re: How to print the content of Table/, Emeka
 
- Re: How to print the content of Table/, Craig Barnes
 
- Re: How to print the content of Table/, Emeka
 
- Re: How to print the content of Table/, Miles Bader
 
- Re: How to print the content of Table/, steve donovan