lua-users home
lua-l archive

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


They are not isolated, there is a "single linked list" by __index fields, and you got the last element of this list instead of first.

As __index is used (mostly i suppose) for things like emulating OOP "inheritance" it is quite strange that when indexing a child, "this->" eventually becomes a pointer to the most parent.

If it is really necessary to get parents i could iterate manually __indexes from bottom to top, but if got only the last top base table as argument in __index metamethod, there is no way to get back to child instance, who actually triggered the __indexing, and whose internal data i need in that metamethod.

On Sat, 26 Aug 2023 12:53:14 +0300
 Spar <developspartv@gmail.com> wrote:

Because it's a metatable of a different table, each __index is isolated from each other

On Aug 26, 2023 at 11:14 +0300, temp 213 qwe <temp213@gorodok.net>, wrote:
It is a more general question why in this __indexing chain
when finally found __index metamethod is a function, it is
called with last table in chain as argument, but not the first one who actually triggered indexing.

best regards,
Pavel