[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: table.clear
- From: Luther <lutheroto@...>
- Date: Fri, 13 Dec 2013 15:22:11 -0500
On Fri, 2013-12-13 at 12:00 -0800, Coda Highland wrote:
> 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.
> > 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
I did see that thread, but when Andrew says "When someone sets the list
to `nil`, i need to clear it.", it sounds like this:
local list = createListAndFillItWithStuff()
-- This magically clears the table, not the variable.
list = nil
I don't see how else to interpret his question.
Luther