On 4 Apr 2019, at 15:04, Vitor Medina Cruz <vitormcruz@gmail.com> wrote:
Steven:
Oh! I was unaware of these methods under reflection protocol! I manage to make it work, and it is simply AWESOME!! :)
Marcus:
I wanted to intercept the store generally, with any kind of slot, kind of an AOP aproach. I did this:
| slotLink |
slotLink := (MetaLink new metaObject: [Transcript show: 'ihaaaa!!!!']; selector: #value; arguments: #(); control: #before).
TestObject link: slotLink toSlotNamed: #b option: #write.
And it worked like a charm! By you explanation, this would lead to some performance penality, but it seems a really powerfull mechanism to me, and it's performance should be similar to that of extending a Slot, no?
From a bytecode perspective it is the same as if you would make a Slot *and* implement bytecode generation. (with the slight overhead of the block execution).
So yes, a nice solution. In general, MetaLinks are nice if you want to do âmagicâ that are not supposed to be visible. Making a Slot subclass makes a change more explicit. Both have their value, depending on the situation. Marcus