[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Invalid key for "next" - Setting value nil while traversing
- From: Roberto Ierusalimschy <roberto@...>
- Date: Tue, 3 Mar 2009 10:57:54 -0300
> 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.