lua-users home
lua-l archive

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


Yeah, but I am thinking it would be another metatable that would be listening and responding to the metatable change notification.

So object O is assigned metatable M which is wrapped by metatable W. Then accesses are responded to by O, W, M in turn.

At some point, M decides to change the metatable on O. But W would like to intercept this change, so it can again wrap M with W.

Something like that. I will look more into a meta-meta-table approach. The thing is, though, it won't necessarily be in all cases that M is wrapped by W, or even that in all cases it will be the same W doing the wrapping.

On Mon, Oct 15, 2012 at 5:32 PM, joao lobato <btnfdp.lobato@gmail.com> wrote:
On 10/15/12, Marc Lepage <mlepage@antimeta.com> wrote:
> Yeah, it's just that being notified of setmetatable would facilitate using
> metatables to build state machines (getting notification of the state
> change), and wrapping metatables allows states to be composed, but the
> notification is also necessary for maintaining the wrapping.
>

Isn't the point of metatables that objects are not aware of them? I
mean, when a table does not know what to do it consults its metatable
(that may consult its metatable).

Being notified that your metatable changed sounds like "reversing the polarity".