Maybe you think about newproxy
From: http://lua-users.org/wiki/HiddenFeatures
newproxyis an unsupported and undocumented function in the Lua database library. From Lua code, you can use a function setmetatableon table type objects. The function newproxybypasses the limitation by creating zero user data and setting either a new, empty metataber on it or using another metatable newproxyexample. Then we can change the meta from Lua. This is the only way to create a proxy object from Lua that honors certain metamethods, such as __len.
It is also useful for metathemes __gclike hacking a callback when an instance newproxybecomes free.
This feature was present in Lua 5.1, but removed in 5.2. In Lua 5.2, metamethods __gccan be installed on tables with zero size, so the main impulse for newproxygone.