Table traversal in C

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Table traversal in C

Fred Bertsch
In the FAQ, there's a mention that it will be possible to traverse a lua
table from C in Lua 3.1.  How does that work?  I couldn't find any mention
of it in the alpha docs...

Thanks!

-Fred


Reply | Threaded
Open this post in threaded view
|

Re: Table traversal in C

David Jeske-2
You can always do it by just getting the "next" function and holding a reference
to it. Then call that function with your reference each time. However, it would
be nice if there was a straight lua_nextelement() type function for walking a
table more-directly. (i.e. what if "next()" is no longer a global variable :)

I looked quickly though the beta 3.1 "lua.h" and didn't see anything which
looked like it would do this.

On Wed, Feb 18, 1998 at 02:28:55AM -0200, Fred Bertsch wrote:
> 
> In the FAQ, there's a mention that it will be possible to traverse a lua
> table from C in Lua 3.1.  How does that work?  I couldn't find any mention
> of it in the alpha docs...

-- 
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Table traversal in C

Luiz Henrique de Figueiredo
In reply to this post by Fred Bertsch
>From [hidden email] Wed Feb 18 02:28:34 1998
>
>In the FAQ, there's a mention that it will be possible to traverse a lua
>table from C in Lua 3.1.  How does that work?  I couldn't find any mention
>of it in the alpha docs...

3.1 has new functions "foreach" and "foreachvar".
You call them from C with lua_call.
--lhf