lua-users home
lua-l archive

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

I haven't checked 5.1 final, but earlier versions of 5.1 would crash if you
did this because components such as the GC assumed it wouldn't be nil.

I would expect that there would actually be a performance win to supporting
nil since the GC could avoid repeatedly tracing the superfluous link.


on 3/20/06 10:37 AM, King, Mike at wrote:

> Is it okay to set the metatable of a userdata to nil?  In my C++
> program, a Lua function handles a C++ event.  I'm pasting to it a
> userdata that has a metatable associated with it.  I want to prevent the
> functions of the userdata's metatable from being called after the event
> has occurred.  I'm thinking I can do this by setting the userdata's
> metatable to nil after the event has been invoked.