lua-users home
lua-l archive

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

> I thought it was legal to assign nil to existing keys inside a loop.
> Are there further caveats that need to be observed in Lua 5.1?

It was in Lua 5.0.2...  Now I'm a bit confused about what the intended
behaviour in 5.1w2 is...  The following code is the cause of this change if
I'm not mistaking:

file lgc.c line 65:

    static void removeentry (Node *n) {
        setnilvalue(gval(n));  /* remove corresponding value ... */
>       if (iscollectable(gkey(n)))
>           setttype(gkey(n), LUA_TNONE);  /* dead key; remove it */

if you remove the indicated lines, iteration is OK again.  (Lots of other
stuff will probably break??  :-) )  What is the reason for this change in gc
behaviour wrt tables?