lua-users home
lua-l archive

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

> That I understand; what I don't get is why this precludes a MT check.

There is a hidden rule in Lua that only the creator of a table should
set (or change) its metatable. Other code may change a metatable's
fields, but should not change the metatable itself.

So, in the case of modules created with the "module" function, only the
package system should set the module's metatable. Whenever it does that
it also sets the _NAME field; therefore, to test for a MT is redundant
with the test for _NAME.

After "module" sets a module's metatable, it is OK for another code
to add a __call metamethod on it.

-- Roberto