lua-users home
lua-l archive

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

On Sat, 27 Apr 2013 06:33:02 +0200
Dirk Laurie <> wrote:

> 2013/4/26 Steve Litt <>:
> > I can't think of any reason for a global variable's
> > existence to be conditional.
> That's because you are accustomed to having no distinction between
> nonexistent and nil-valued global variables. Highly convenient.

Under what circumstances would the distinction between nonexistant and
nil-valued globals be convenient?

> The main difference _in practice_ between a local and a global
> variable is that `local x` (which is syntax sugar for `local x=nil`)
> fixes the point on the main Lua stack where `x` will be stored. It
> uses up one of the precious 200 slots in the current stack frame that
> are available for the purpose. 

LOL, the day I use 200 variables in one function, you should shoot me
and put me out of my misery. Long before I got to 200, just for the
wellbeing of my brain, I'd arrange them in data structures, which for
the purposes of Lua means tables suitably nested.


Steve Litt                *
Troubleshooting Training  *  Human Performance