lua-users home
lua-l archive

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

> 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