Unexpected order of __finalize
Max McGuire <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
I've run into some unexpected behavior with the __finalize method.
Specifically if my class has members that are also classes, the __finalize
methods for the members are getting called before the __finalize method for
the owner.
Here's a simple example:
class 'B'
function B:__finalize()
print("B:__finalize\n")
end
class 'A'
function A:__init()
self.b = B()
end
function A:__finalize()
print("A:__finalize\n")
end
local a = A()
a = nil
collectgarbage("collect")
The output from this program is:
B:__finalize
A:__finalize
This is the opposite behavior that you would get from a C++ program and is
problematic, especially if B is actually a class implemented in C++ and you
tried to access b during the __finalize method for A.
Is this by design or am I missing something?
Thanks,
Max
--
Technical Director
Unknown Worlds Entertainment
http://www.unknownworlds.com
------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:
Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
luabind-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/luabind-user