[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: table.clear
- From: Luther <lutheroto@...>
- Date: Fri, 13 Dec 2013 14:28:47 -0500
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