[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: table.clear
- From: Coda Highland <chighland@...>
- Date: Sat, 14 Dec 2013 01:42:02 -0800
On Fri, Dec 13, 2013 at 11:34 PM, Ulrich Schmidt <u.sch.zw@gmx.de> wrote:
> 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.
I explained this in an earlier post -- the difference is if there's
more than one reference to the table hanging around. Making a new
table in Lua code and assigning it to the variable leaves those other
tables unaltered, which is almost surely NOT what you wanted to do.
/s/ Adam