[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Non local variables not becoming global?
- From: Scott Vokes <vokes.s@...>
- Date: Tue, 19 Oct 2010 16:38:55 -0400
On Tue, Oct 19, 2010 at 1:23 AM, Saptarshi Guha
> Is there anyway to force chunks to create variable in the current context rather
> than in global when local is not specified?
That's what local is *for*.
If you're worried about accidentally making global variables, look
at strict.lua in the standard Lua distribution - it uses the global
table's metatable to intercept any attempts to set global variables
that haven't already been declared. While having variables be "global
by default" seems dangerous, in practice any problems it could cause
are easily prevented.