[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Clearing tables
- From: Wim Couwenberg <w.couwenberg@...>
- Date: Sun, 18 May 2003 13:48:06 +0200
On second (or third?) thought, I'd suggest a slightly
altered version of the C implementation of zap_table:
/* suppose that the table is at stack index "table" */
void zap_table(lua_State *L, int table)
{
while (lua_pushnil(L), lua_next(L, table))
{
lua_pop(L, 1); /* pop value */
lua_pushnil(L);
lua_settable(L, table); /* zap the key */
}
}
This does not rely on "nil-valued" fields at all and is even
a bit shorter... :-)
Bye,
Wim