[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Non local variables not becoming global?
- From: Saptarshi Guha <saptarshi.guha@...>
- Date: Tue, 19 Oct 2010 13:51:30 -0700
Thanks all.
On Tue, Oct 19, 2010 at 1:38 PM, Scott Vokes <vokes.s@gmail.com> wrote:
> On Tue, Oct 19, 2010 at 1:23 AM, Saptarshi Guha
> <saptarshi.guha@gmail.com> wrote:
>> 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.
>
> Scott
>