[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Is this Lua table an array?
- From: Sam Roberts <sroberts@...>
- Date: Wed, 4 Oct 2006 11:26:57 -0700
On Wed, Oct 04, 2006 at 01:28:09PM +0530, Ashutosh Sharma wrote:
> I am writing a bridge between Lua and JavaScript. If it is known that
> a table is actually an array, one can then create a JS array rather
> than a generic JS Object.
Good reason!
> 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
Cheers,
Sam