lua-users home
lua-l archive

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


Le Fri, 13 Nov 2009 11:08:55 +0100,
Jerome Vuarand <jerome.vuarand@gmail.com> s'exprima ainsi:

[snip]
Thanks for you hints, Jerome.


> > * Is there a standard way to copy (clone) lua objects --especially tables?
> 
> There is no single way to do that. What about subtables ? Should they
> be referenced by the new table, or cloned too ? What about recursive
> references (t={}, t.itself = t) ? What about non-clonable members
> (full userdata) ? You need to answer all these questions before
> writing a table dump function, and my answers are probably not the
> same as yours.
> 

You're right, for sure. Thought at upper level copy, so non-atomic items remain shared references. I have a clone() that just iterates at top-level.

Denis
--------------------------------
* la vita e estrany *

site: http://spir.wikidot.com/