lua-users home
lua-l archive

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


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