lua-users home
lua-l archive

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



-----Original Message----- 
> From: "Dirk Laurie" <dirk.laurie@gmail.com> 
> To: "Lua mailing list" <lua-l@lists.lua.org> 
> Date: 27-04-2013 21:22 
> Subject: Re: Local and Global Variables 
> 
> 2013/4/27 Steve Litt <slitt@troubleshooters.com>:
> > On Sat, 27 Apr 2013 06:33:02 +0200
> > Dirk Laurie <dirk.laurie@gmail.com> wrote:
> >
> >> 2013/4/26 Steve Litt <slitt@troubleshooters.com>:
> >>
> >> > 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?
> 
> Never, as fas as I am concerned, but if we are to have compulsory
> declaration of global variables, such a distinction may well come into
> existence, as there at present is for locals.
> 
> > 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.
> 
> Not in a function, no, but in a module's main file, dead easy.
> 
Setting globals in modules is depreciated:
"Modules are not expected to set global variables." - http://www.lua.org/manual/5.2/manual.html#8.2

Just use a local table instead. You don't have any limits there.
--
Thomas