lua-users home
lua-l archive

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

On Mon, Feb 21, 2005 at 03:23:37PM -0300, Roberto Ierusalimschy wrote:
> > In loadlib.c, ll_module attributes a new metatable to a module. Wouldn't
> > it be nicer to check for a previously assigned MT first?
> It checks for a _NAME field. It assumes that, if the module does not
> have this field, it was not initialized, and therefore also does not
> have a metatable. (Conversely, if it does have that field, it is
> not initialized again and does not get a new metatable.)

That I understand; what I don't get is why this precludes a MT check. With
respect to the module's MT, since in the initialization you only set a __index
field, the assumption should be that the MT does not contain such a field, and
_not_ that the MT does not exist, right? That is, your concern (so far) should
be the __index field, and not the whole table.

It's not like I'm complaining about it. But this quick check would allow
easier module metatable setups from C.

--luis, low on coffee. :)

A mathematician is a device for turning coffee into theorems.
        -- P. Erdos 

Luis Carvalho
Applied Math PhD Student - Brown University
PGP Key: E820854A <>