lua-users home
lua-l archive

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


On Fri, Dec 13, 2013 at 11:28 AM, Luther <lutheroto@gmail.com> wrote:
> 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

I believe what you've missed is a recent thread requesting a
table.wipe function to the C API that could wipe a table more
efficiently than iterating over the contents and nil'ing out every
entry. This appears to be a request for functionality in this proposed
function.

/s/ Adam