[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: when do programs set metatable?
- From: Doug Rogers <rogers@...>
- Date: Fri, 08 Feb 2008 13:15:17 -0500
Wesley Smith wrote:
> On Feb 8, 2008 6:45 AM, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
>> More often than not, programs set the metatable of a userdata right
>> after creating the userdata. Does anyone know of relevant counterexamples
>> to this pattern?
> What thoughts are behind this question? I'm curious.
> best,
Sounds like an optimization for allowing the GC to make assumptions
about metatableless userdata. I wonder what it is.
Would it be possible to deprecate the __gc metamethod and simply provide
a C function to be called in lua_newuserdata()? It actually sounds like
a pretty good idea. To be backwards compatible, though, it would require
a little more work - perhaps the penalty?
The __gc metamethod does seem to be an exceptional case. It is only
available for userdata, which are only available to the C API. Seems
ripe for simplification.
Doug
--
Innovative Concepts, Inc. www.innocon.com 703-893-2007 x220