[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: little questions
- From: spir <denis.spir@...>
- Date: Fri, 13 Nov 2009 11:32:27 +0100
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/