lua-users home
lua-l archive

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


On 10/18/07, Graham Wakefield <lists@grahamwakefield.net> wrote:
>
> Seems like the gc method isn't registered in the metatable. Are you
> expecting it to be passed in with the luaL_reg?

Yes, because the default gc method might not be appropriate in all
cases, so I leave it up to the caller to fill it in luaL_reg.

> Might also want to use your check() function inside your gc() function,
> since the __gc metamethod itself will be exposed to Lua (yes, this surprised
> me too):
>
> local a = Udata1.new()
> local b = Udata2.new()
>
> local gc = getmetatable(a).__gc
> gc(b) -- nasty!

This is nasty indeed, I will fix my code.  Thanks for the suggestion.

regards,
panagiotis.