lua-users home
lua-l archive

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


in C, use lua_pushnil() and lua_settable() or lua_rawset()

Will that collect the key or could I end up with a large table of
nil values ? (just checking!)

and although unlikely what would happen if I wanted a table that
contained nil values ie is nil some special construct and not just zero
(again just need to be sure I understand what's happening)

Thanks
Chris


Javier Guerra wrote:
On Fri, Aug 21, 2009 at 2:47 PM, Chris Camacho<c.camacho@ntlworld.com> wrote:
I have a table indexed by pointers (lightuserdata) with userdata values
to allow me to look up pointers and return userdata to Lua

However in the userdata's __gc method I need to remove the
pointer key from the table, there seems to be no analogue of
table.remove(t,i) in lua's C api - or am I missing something obvious

table.remove(t [,pos])  is handy for working with the array part of a
table, not the hash part where you're storing your userdatas (since
they're indexed by lightuserdatas and not small consecutive indexes).

for the hash part, simply assign nil:   t(yourlightuserdata)=nil

in C, use lua_pushnil() and lua_settable() or lua_rawset()



--
Disclaimer:
By sending an email to ANY of my addresses you are agreeing that:

  1. I am by definition, "the intended recipient"

  2. All information in the email is mine to do with as I see fit and
make such financial profit, political mileage, or good joke as it lends
itself to. In particular, I may quote it where I please.

  3. I may take the contents as representing the views of your company.

  4. This overrides any disclaimer or statement of confidentiality that
may be included on your message.