lua-users home
lua-l archive

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


On Mon, Dec 7, 2009 at 10:06 AM, spir <denis.spir@free.fr> wrote:
> * Say an "object"'s metatable __index field points to a "type". The object will not "inherit" the type's metatable (eg the __tostring field). Meaning print(object) will not use the func pointed by the type's metatable __tostring field. We need to transmit the whole of the type's metatable to instance objects.

There are various strategies. The one described in

http://lua-users.org/wiki/SimpleLuaClasses

does inheritance by copying the base class metatable methods (and
metamethods) into the new metatable.  This gives better performance
than having to do a lookup along the chain of metatables for deeply
inherited classes.

steve d.