[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re[2]: Local and Global Variables
- From: "Thomas Jericke" <tjericke@...>
- Date: Sun, 28 Apr 2013 12:17:47 +0200
-----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
- References:
- Local and Global Variables, moonfruit
- Re: Local and Global Variables, Geoff Leyland
- Re: Local and Global Variables, Pierre Chapuis
- Re: Local and Global Variables, William Ahern
- Re: Local and Global Variables, Thomas Jericke
- Re: Local and Global Variables, Steve Litt
- Re: Local and Global Variables, Thomas Jericke
- Re: Local and Global Variables, Steve Litt
- Re: Local and Global Variables, Dirk Laurie
- Re: Local and Global Variables, Steve Litt
- Re: Local and Global Variables, Dirk Laurie