[Newbies] Trace through calls
goran at krampe.se
Mon Apr 4 21:02:04 UTC 2011
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.
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.
More information about the Beginners