lua-users home
lua-l archive

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


Hi,
I have a situation where a Lua table contains several userdata that 
are pointers to C++ objects.  When the table is garbage collected, I 
need to delete the C++ objects in a particular sequence, otherwise it 
will lead to dead/dangling C++ pointers.

By setting "gc" tag methods on the userdata, I get a chance to delete 
the C++ objects, but I'm not guaranteed that the tag methods are 
called in any particular sequence.

All I need is to be able to set a "gc" tag method for the table. Then 
within the tag method the programmer can delete the C++ pointers in 
any appropriate 
sequence. Unfortunately, Lua 4.0b allows "gc" tag methods to be set 
only for the userdata.  What is the reason for this? and can this 
decision be changed before the release of 4.0?

I believe that in 3.2 you could set "gc" tag methods for tables.  Am 
I correct ?

Cheers,
PYI