[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Garbage collection
- From: Shmuel Zeigerman <shmuz@...>
- Date: Sun, 10 Sep 2006 17:20:21 +0200
Vyacheslav Egorov wrote:
Shmuel Zeigerman wrote:
That is necessary only if you plan to use metatable as a place where Lua
will look _userdata_ fields. It is a common (yet newbie-confusing)
practice to store methods in metatable, instead of special separate table.
You probably forgot to assign the "__index" field
of the metatable to the metatable itself:
lua_pushvalue(L, -2); /* push metatable */
lua_rawset(L, -3); /* metatable.__index = metatable */
Yes, you're right.
"__gc" doesn't have to be a field of the userdatum,
it has to be a field of its metatable.
Thanks for pointing that out.