[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: when do programs set metatable?
- From: Edgar Toernig <froese@...>
- Date: Sat, 9 Feb 2008 03:41:11 +0100
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.
PS: setmetatable shouldn't raise out-of-memory errors ...