[Newbies] Determining the sender in a method

Rob Rothwell r.j.rothwell at gmail.com
Sun May 25 01:52:33 UTC 2008


Is there a way to determine "who" called "me" in a method?  Or would doing
this just be bad form?

I have a method in an object that creates another object FOR the sender.
Rather than pass a parameter, it seemed like it would be nice to just "know"
who was asking for the component.

For example, rather than

MyObject>>doSomething
     WidgetBuilderSubclass buildComponentForObject: self anObject.

it would be nice to just

MyObject>>doSomething
     WidgetBuilderSubclass buildComponent

and have

WidgetBuilderSubclass>>buildComponent
     | obj widget |
     obj := self thisMessageSender anObject.
     ...
     ^widget

I am probably asking a question that shows just how much I don't understand
"the Smalltalk way!"

Thanks,

Rob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20080524/3b3b8f5f/attachment-0001.htm


More information about the Beginners mailing list