[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Module finalization (along the lines of calling a function on exit)
- From: Antero Vipunen <antero@...>
- Date: Fri, 19 Aug 2005 19:04:58 +0700
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...
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?