lua-users home
lua-l archive

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


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