[Newbies] Trace through calls

Levente Uzonyi leves at elte.hu
Tue Apr 5 00:37:53 UTC 2011


On Mon, 4 Apr 2011, Göran Krampe wrote:

> On 04/04/2011 10:22 PM, Rick H. wrote:
>> Hello.  I am trying to get a handle on how things are are called.  I might
>> like to make some changes to standard morphs for my own purposes.
>> 
>> I can put the cursor on a morph, and inspect it, or debug it.  Can I put 
>> the
>> cursor on it and say "I want this morph, and all of its submorphs, to make 
>> a
>> note on the Transcript each time a method is entered?"
>>
>>               Regards, Rick
>
> Not typical beginner stuff, but here goes:
>
> Anything is possible - and my first idea on how to do that was to "wrap" the 
> morph (and all its submorphs individually) in a so called "wrapper" object 
> that delegates all messages to its wrappee - but first prints something of 
> course.
>
> Constructing such a wrapper that is properly "invisible" can be a bit tricky 
> but basically one can create a class inheriting from ProtoObject (instead of 
> Object) which means it will have NO inherited behavior, and then implement 
> doesNotUnderstand: to do the delegation. Such a class will be "utterly 
> stupid" and thus fairly invisible. Things making it complicated are identity 
> - you would need to do the "wrap" using the magical become: message. And you 
> would need to make sure the wrappee doesn't "leak" itself out as an answer to 
> a message - in unwrapped form. As you realize it gets tricky.

I'm sure this method is sufficient for Rick's goal, but Squeak has a 
better mechanism for proxies, which allows all real message sends to be 
captured. Igor wrote some classes* which simplify proxy creation, by 
implementing the boilerplate stuff. The problem with this method is that 
older VMs don't fully support this mechanism, but this is definitely the 
best solution for the future, so expect this to be added to the Trunk 
soon.


Levente

*http://code.google.com/p/pharo/issues/detail?id=3648

>
> Then I remembered that there is something called MethodWrappers that can be 
> used to do similar "augmentation", but on a method by method basis instead of 
> on the object level. I am pretty sure that is a much more bullet proof 
> approach. Haven't used that package myself though.
>
> regards, Göran
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>


More information about the Beginners mailing list