lua-users home
lua-l archive

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

Roberto Ierusalimschy wrote:
> More specifically: if Lua puts a cost on setting the metatable of an
> object long after its creation (the longer the more expensive), do you
> know of programs that would be hurt?

On manual finalization (something like fh:close()) I reset the metatable
of that userdata to nil ("I'm done with it - never wanna see it again.").

Modules using this scheme of manual finalization have as many "early
setting" setmetable calls as "late resetting" setmetable calls.
*Both* should be reasonably fast.

Ciao, ET.

PS: setmetatable shouldn't raise out-of-memory errors ...