[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: table.clear
- From: Dirk Laurie <dirk.laurie@...>
- Date: Sat, 14 Dec 2013 08:37:27 +0200
2013/12/13 Coda Highland <chighland@gmail.com>:
> 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.
It was not obvious to me during that discussion, and it is even
less obvious now, that it is so very inefficient to do exactly that.
In fact, I can't see how any C routine would be able to avoid
doing it. Andrew's neat exploitation of the generic `for`:
for i in next, t do t[i] = nil end
is clear enough for me.