[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Metamethods and inheritance
- From: Ulrich Schmidt <u.sch.zw@...>
- Date: Tue, 31 Oct 2017 12:32:26 +0100
Am 31.10.2017 um 11:24 schrieb Dirk Laurie:
.__index can be a function instead a pointer to a 2nd table. You can do
what you want in this function. I suggest, you take a look into
middleclass how they do. But "__index"-ing from one table to the next
to the next to the next .... is time consuming, so take care.
I have an object with metatable RECORD and several objects which are
specialized RECORDs, with metatables OBJ1, OBJ2 etc. There are certain
methods and metamethods that are common to all RECORDs and others that
are specific to each specialization.
For non-meta methods the situation is easy: OBJ1.__index = RECORD.
However, for metamethods, access is raw. There is no other way except
copying the metamethods from RECORD into OBJ1 etc.
Or is there?