lua-users home
lua-l archive

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


You are right. May be i am to much lua beginner to see the benefit of your approach compared to

tablevar = setmetatable({}, getmetatable(tablevar))

The only difference i can see is, that table.clear() would do (parts of)
the _gc job sooner.

Ulrich

Am 14.12.2013 08:27, schrieb Coda Highland:
On Fri, Dec 13, 2013 at 11:19 PM, Ulrich Schmidt <u.sch.zw@gmx.de> wrote:
This shows me both tables t1/t2 points to the same table tx. let's think
about what happens if i would do a T2:clear():
In case the clear clear function wants to free all t2 entries immediately,
the clear function needs to check double references for each table item of
type table/function.

Why would it FREE all T2 entries immediately? It can just orphan them,
and then they'll get collected next sweep, and when that happens, __gc
will run.

/s/ Adam