I wondered how these two things are related.
Will slots be giving MWs facilities out of the box?
When should I use both?
Hello,
Slots are about state (instance variables), while method wrappers are about methods
(and hooking into method execution). So they are not directly related, but there is indeed
a connection :-)
The MetaLinks (which we will get for real in Pharo5, I sadly did not finish it for Pharo4)
can be seen as a generalisation of MethodWrappers. They are much more flexible and
apply not to whole methods, but any ���structural��� reflective entity.
This means any node in the AST, but, in addition, slots. This means you can put a meta-link
on a slot (e.g. one describing a normal instance variable) and call meta-object before, after
or instead. Which in some way means that you can put a ���wrapper��� on an instance variable.
The meta-link machinery will indeed completely replace method wrappers. You can implement
method wrappers using them if you need them, but in most cases using directly the link will
be exactly what you need.
I am sure we will use this *a lot* for the tools. E.g. breakpoints will use links to hook into execution.
Or the inspector will use them to get notified on state change to update the display��� an many more.
Marcus