lua-users home
lua-l archive

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


On 3/1/06, Michael Broughton <mbobowik@telusplanet.net> wrote:
> Am I the only person who thinks there should be shallow and deep copy
> functions in the table library? Or at least in the Wiki? Perhaps even
> three functions... shallow, deep, and deep with refs.

I'd love to see that. In fact, I work with a custom C library now that
does something interesting, which is a deep copy with internally
consistent references (or maybe that's what you meant by "deep with
refs"?). In other words, if you setup this table:

oldtbl["a"] = {"somedata"};
oldtbl["b"] = oldtbl["a"];

you can copy it to newtbl such that newtbl["a"] would be a new copy of
the "somedata" table, and newtbl["b"] would be a reference to the
*new* table copy in newtbl["a"].

I know, wishful thinking, but anyhow...

- K.Howe