[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Array access indirection
- From: "Wesley Smith" <wesley.hoke@...>
- Date: Sun, 21 Sep 2008 12:51:14 -0700
> Just a suggestion, but in addition it would probably suit you more to do:
>
> rt={} -- new empty table
>
> rt[var]={}
> rt[var][pa1]=va1
> rt[var][pa2]=va2
>
> var="eek" -- change table
>
> rt[var]={}
> rt[var][pa1]=va1
> rt[var][pa2]=va2
>
> etc. since you will probably be doing it in a loop anyway, I imagine.
>
> Matthew.
>
my personal preference for nested table style is:
rt = {}
local t = {}
t[pa1] = va1
t[pa2] = va2
rt[var] = t
var="eek"
local t = {}
t[pa1] = va1
t[pa2] = va2
rt[var] = t
if it's in a loop (i.e. the above is unrolled) because it's cleaner in
my view (less "dereferences") and saves table accesses
or even better
rt = {
[var] = {
[pa1] = va1,
[pa2] = va2,
},
...
}