lua-users home
lua-l archive

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



On August 25, 2023 12:58:40 PM EDT, temp 213 qwe <temp213@gorodok.net> wrote:

>"child" table could store a link to "parent" (in __index actually), but
>if at 
>the end of nested __indexing process we got last "parent" as self,
>there is no 
>way to get a child who actually triggered it, or?

If I understand correctly what you are asking, this is a common request.

You have two options, either use functions for __index all the way down and choose a technique to carry a reference to the original table into successive calls, or modify the Lua runtime to pass in the originating table to the final __index function as a third parameter.

I use a personal fork of Lua with this modification amongst others, and I imagine that I am not the only one.

See for instance: http://lua-users.org/lists/lua-l/2016-02/msg00287.html

-- David