>>>>> "Rob" == Rob Rothwell <
[hidden email]> writes:
Rob> Is there a way to determine "who" called "me" in a method?
Yes, see the methods of "thisContext", a special variable
that represents the currently executing context. The methods
are defined in MethodContext, on which a protocol-browse will reveal
some really interesting (and horribly introspecting) methods, such
as "thisContext sender".
Rob> Or would doing this just be bad form?
Yes. While you *can* do a lot of magic like this, it's probably
best if you avoid it for now. A typical pattern is to pass self:
MyObject>>doSomething
^self otherClass makeSomethingOn: self.
Also note: don't hardwire a helper class name in your methods. Use
a method call to get it, so you'd say:
MyObject>>otherClass
^TheOtherClass
If you hardwire it, it'll make your class much harder to subclass.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<
[hidden email]> <URL:
http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See
http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners