2015-08-12 22:56 GMT+02:00 Soni L. <fakedme@gmail.com>:
Currently:
t = setmetatable({}, setmetatable({}, {__index={__metatable="test"}}))
print(getmetatable(t) == debug.getmetatable(t))
Can we get getmetatable() to respect __index?
When is __index called? When some key in the original table is not
found. But when __index exists, then the metatable must exist too.
If getmetatable is to behave like an array access, then __index must
not be invoked.
Moreover, getmetatable does not return __metatable because
__metatable is a surrogate for the metatable. It is not that.
It is a lock, i.e. its presence prevents access to the metatable.