lua-users home
lua-l archive

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

This is exactly the part in the manual I read and assumed it was for
just the scripting language, and not the C API, which I am using. But
since making the change to pushnil to pushinteger 0, it has fixed the

I'm still unsure why.


On Tue, Mar 3, 2009 at 5:57 AM, Roberto Ierusalimschy
<> wrote:
>> Now, I ask, should I not ever be setting a value to nil mid-traversal?
>> Why does this cause problems as I'm not modifying the key at all? My
>> initial assumptions were that some sort of GC was occuring before the
>> next iteration, which confused lua_next, since the value was GC'd
>> (nil). Is this correct?
> This should cause no problems. It is explicitly allowed:
>  *
>  The behavior of next is undefined if, during the traversal, you assign
>  any value to a non-existent field in the table. You may however modify
>  existing fields. In particular, you may clear existing fields.
> -- Roberto