lua-users home
lua-l archive

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


Am 30.05.2011 14:53, schrieb Joerg Walter:

Tables are objects in the LUA world. I'm looking for an identifier for the C world. If I wanted to write a table traverser in LUA I would put the table itself as a key into another table to remember that this table has been visited.
I'm looking for the c/c++ equivalent: Putting the table id into an std::set.

My ideas:

1. Using the registry mechanism. But I don't know how this behaves with references on tables.

2. Simply using lua_topointer(): Same question

You can always get the reference of an object in a table using luaL_ref. When I have to do similar things as you want to accomplish, I keep the tuple reference of the object/reference of the table the object is part of.


-------- Original-Nachricht --------
Datum: Mon, 30 May 2011 09:20:10 -0300
Von: "Ignacio Burgueño"<ignaciob@inconcertcc.com>
An: Lua mailing list<lua-l@lists.lua.org>
Betreff: Re: Identifiers of tables on Stack from C/C++

On Mon, May 30, 2011 at 4:05 AM, Joerg Walter<joerg-walter@gmx.de>  wrote:

Hi

I'd like to cylce through a table variable from a C function. Since
tables
can contain references on tables and since this can result in cyclic
structures I need to know somehow that I'm am stuck in a cycle at some
point. I have save remember which table I already have visited. What is
an
appropriate identifier of a table and how can I retrieve it from C?



Can't you use the table itself as the key?