lua-users home
lua-l archive

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


Make a dummy table with metatable and __pairs metamethod in it, make that metamethod return value A, put value B in dummy table.
Now call pairs on it and read first value. If __pairs was invoked, you get A, if not regular pairs will return B 
On 21 Dec 2021, 12:44 +0300, Александр Машин <alex.mashin@gmail.com>, wrote:
Dear all,

Is there a way to find out whether metatable methods __pairs() and
__ipairs() are invoked by pairs() and ipairs() other than
checking _VERSION (my code will be run in an exotic environment)
or probing, i.e. defining such metamethods for a dummy table and
checking, if they are actually called?

Alexander Mashin