lua-users home
lua-l archive

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


On Fri, 2013-12-13 at 12:52 -0600, Andrew Starks wrote:
> I was working with defining an "object" that holds a list. Due some
> ways in which it'd be used, the list has a metatable. When someone
> sets the list to `nil`, i need to clear it.

> 1: It not wipe out the metatable.
> 2: There be a __clear/wipe metamethod so that I can use the same call
> and also catch any cleanup that may need to happen as a result, in
> cases where a simple wipe would be problematic.

Maybe I misunderstand your question. As a Lua coder, when I assign nil
to something, I expect the former value to simply be deleted (assuming
no other references). Would it not be better to write a 'clear' method
that does what you want?

Luther