lua-users home
lua-l archive

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


On Fri, Dec 13, 2013 at 1:04 PM, Andrew Starks <andrew.starks@trms.com> wrote:
> On Fri, Dec 13, 2013 at 2:30 PM, Ulrich Schmidt <u.sch.zw@gmx.de> wrote:
>> tablevar = setmetatable({}, getmetatable(tablevar))
>
> Kind of a sweet argument against a table.clear method existing at all,
> but you'd have to revisit
> http://lua-users.org/lists/lua-l/2013-11/msg00669.html for that
> discussion, no?

Calling back to the previous discussion:

othervar = tablevar
tablevar = setmetatable({}, getmetatable(tablevar))
-- othervar still contains original table

vs.

othervar = tablevar
table.clear(tablevar)
-- othervar is empty now

This is really the main reason why clear should exist. Everything else
is just sugar -- this behavior is important.

/s/ Adam