Ok by digging a bit, i found that it was a problem in my behavior though
i don't understand it. 

When sending message to self, the #isMetaMessage: returns always true
when evaluating the first test condition GHCurrentMetaLevelDepth value >
0 ifTrue: [ ^true ]. The value returns something higher than 0 and my
"self messages" are considered to be meta-messages. It is very sensible
to modifications, as just removing this test or try to bend it can
freezes the image (just tried to see what would happen). 

I'm a bit lost, what should i do to consider "self messages" not "meta"
in the behavior ? 

Le 2016-07-28 12:33, Steven Costiou a écrit :

> Hi, 
> 
> I think i am missing something. 
> 
> For example in the following code (took from the tests): 
> 
> | victim virus actual |
> virus := GHObjectVirus behaviour: GHGhostBehaviourStub new.
> 
> victim := 0@0 corner: 3@4.
> virus infect: victim.
> victim corner 
> 
> The evaluation is trapped by the send:to: method in the behavior (i've put a 
> halt there). However if i replace the "corner" message by an inspect of the 
> victim, and if i evaluate "self corner", then the message is processed 
> without going through the send:to: method of the behavior. It is not halted 
> and the victim responds immediately to the message. I have also tried to add 
> a new method in the Rectangle class that calls "self corner". When called in 
> the playground, my new message is trapped but not the "corner" sent to self. 
> 
> From what i understand it could be related to the behavior i use, but i don't 
> see what's missing.    
> 
> Le 2016-07-28 11:35, Denis Kudriashov a écrit : 
> I think I not understood second part of "self problem" in this paper. But 
> self sends are covered by virus as I described. 
> 
> 2016-07-28 11:30 GMT+02:00 Denis Kudriashov <dionisi...@gmail.com>:
> 
> 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.

-- 
kloum.io 

Reply via email to