[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Notification of metatable change?
- From: Marc Lepage <mlepage@...>
- Date: Mon, 15 Oct 2012 17:43:23 -0400
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 <firstname.lastname@example.org>
Isn't the point of metatables that objects are not aware of them? I
On 10/15/12, Marc Lepage <email@example.com
> 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.
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".