Hi

2016-07-27 22:19 GMT+02:00 Steven Costiou <steven.cost...@kloum.io>:

> Hi,
>
> I use virus from Ghost to intercept messages sent to a given object and
> adapt methods behaviors for this particular object only. However it would
> seems that doing interception this way is subject to the "self problem"
> described in this paper from Stéphane (DUCASSE, Stéphane. Evaluating
> message passing control techniques in Smalltalk. *JOURNAL OF OBJECT
> ORIENTED PROGRAMMING*, 1999, vol. 12, p. 39-50).
>
> I understand i could do instance based adaptation using an other
> technique, but i wonder if there is any way with Ghost to deal with this
> "self problem" problem ?
>
I think "self problem" is only related to classic proxies when objects stay
behind them. But ObjectVirus is not proxy in this meaning. When you infect
your object by virus it is not replaced by somebody else. It is same
original instance but with overridden behaviour. That's why I call it virus
without any relation to proxies.
Any message to infected object is processed by your behaviour. All self
sends are intercepted. But there are few exceptions:
- special messages like ==,ifTrue/ifNil are not intercepted
- meta messages are not intercepted. They processed by Ghost mechanics but
they not passed to your behaviour. Meta messages defined by
#currentMetaLevel of your behaviour. You could implement it like:


YourGhostBehaviour>>currentMetaLevel

^GHMetaLevel empty


Empty meta level means that all messages will be passed to your behaviour.
There is also "GHMetaLevel standard" which is default one. It makes most of
"tool messages" not interceptable. For example #printString, #class,
#instVarAt: will be not intercepted. It's messages which are usually used
by tools like inspector and debugger.
Standard meta level simplifies debugging of new behaviours. If you make
mistake somewhere standard messages will be not broken and you could debug
error by tools.

Reply via email to