lua-users home
lua-l archive

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


Salve!

Simple test shows me that you are absolutely correct. __gc is invoked only for fulluserdata. Ok. Then why not to do the following: create a userdata with proper __gc metametod(it's only destiny will be to assure the proper finalization), and assign it to some field of module, or set as upvalue for one of the module functions(for example Z_init()). When the module gets collected then so does it's fields...

AMDG,
 Antero Vipunen.


Vijay Aswadhati wrote:

Most of the code that I have seen for __gc is a bit different from the use case
I have. I understand the part of __gc function being a metamethod and hence can
only be set on the metatable.  But the __gc method will only be invoked for
fulluserdata and not for a regular table -- is that correct?