lua-users home
lua-l archive

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


On Thu, Jul 8, 2010 at 12:45 PM, Mark Hamburg <mark@grubmah.com> wrote:
> Why are globals "bad"?... Why are globals "good"?

I would qualify such discussions with the comment that there are
important aspects of globals and locals in Lua that are specific to
Lua and not to other languages.  For example, the scope of a Lua
global can be a proper subset of the scope of a local, which seemingly
is counter-intuitive, as it was for me [1].  The mantra "globals are
bad", as used elsewhere, therefore is using the term "global" not in
the exact same sense as used here.

So, here's a new page outlining the fundamental differences between
locals and globals as implemented in Lua:
http://lua-users.org/wiki/LocalsVsGlobals .

[1] http://lua-users.org/lists/lua-l/2006-02/msg00358.html -
"global/local a misnomer?"