lua-users home
lua-l archive

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



On 4 Oct 2006, at 19:26, Sam Roberts wrote:


The 'pairs' mechanism is easy enoug to use in Lua code. I'm just
wondering if there's a good way of doing the same from C.

See

	http://www.lua.org/manual/5.1/manual.html#lua_next

Be VERY careful not to modify the key during traversal. In particular,
lua_isnumber() and lua_isstring() modify their args, or at least they
did in 5.0, I don't see specific mention of this in:

	http://www.lua.org/manual/5.1/manual.html#lua_isstring

lua_isnumber and lua_isstring never did modify their arguments, but lua_tostring does. In 5.0 and 5.1, with its current interface lua_tostring _has_ to modify the stack argument in order to keep the GC happy.

drj