lua-users home
lua-l archive

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


On Wednesday 02 February 2011 09:07:51 Patrick Mc(avery wrote:
> > It's not entirely clear what you want to do. You can create new global
> > variables via _G. But why would you want to create local ones that way,
> > why not simply use a table? I'd be interested to hear the use case.
> >
> > Also, I think you meant to write "for i = 10, 1, -1 do".
> >
> > Robby
> 
> Hi Robby
> 
> Thanks, yes "for i = 10, 1, -1 do".
> 
> I wanted to generate a bunch of "free standing tables within a namespace
> but not nested in another table. Each table would be a manufacturers
> part number and would start with letters and end with numbers, i.e
> WOT2930, hence the concatenation.

Hi Patrick,

I've been trying for several days to figure out the disadvantage of having 
these names be keys in a table instead of free standing local variables, and I 
can't think of a reason. What is the disadvantage of having them as keys in a 
table?

Here are some of the name as key advantages I see:

* You can iterate, search and total them
* You can incorporate functions applying to the set of customers into the 
table.
* Your source code is more compact

Anyway, I'd like to hear the advantage of name-as-local-var.

Thanks

SteveT

Steve Litt
Recession Relief Package
http://www.recession-relief.US
Twitter: http://www.twitter.com/stevelitt