lua-users home
lua-l archive

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


> I've hit the cyclical reference issue before (in a utility for saving "data"
> from scripts).  What I came up with was making a temporary table to hold
> references to any reference based objects (i.e. tables, userdata, functions,
> and threads).

I and Andreas seemed to do the same thing.

> In my "data" file I'd then just record the integer ID "reference" in place
> of the whole object.  I'm not sure what you would present best in "print"
> function, but at least you can avoid the endless recursion.

I used the table address as returned by the original tostring. Handy for
debugging and guaranteed to be unique, so would work for serialisation as
well.

> Ain't it great that you can key off of <anything> in Lua tables. :-)

Yup.

-- 
http://www.mupsych.org/~rrt/
Quidquid latine dictum sit, altum viditur (Anon)