Get sender of a message in Smalltalk

Is there a practical way to get the sender of a message in Smalltalk without manually passing self as a Parameter?

To be more concrete: I want to add a class specific prefix to an ID that gets passed to my class, so if ClassA sends (on class side)

ClassB doSomethingWith: 'myId'.

ClassB should internally treat 'myId' as 'ClassB-myId' or something similar.

I have implemented this with an additional parameter which has to be self

ClassB doSomethingWith: 'myId' for: self.

but I would be very glad if there is a solution without this explicit send of self.


You can use the reflective facilities on the execution stack:

thisContext sender receiver

  1. thisContext answers the current stack frame
  2. sender answers the parent stack frame
  3. receiver answers the receiver of the stack frame

This should work in Pharo, VisualWorks and GemStone. Other Smalltalk might use different method names.

Need Your Help

resetting to initial value

iphone cocos2d-iphone

Can anyone please tell me how to reset a multiplexlayer scene in cocos2d

Using pexpect to remove several files from a directory in a Linux terminal

python linux pexpect

I would like to remove several files with similar names from the directory my python code is in. Doing this manually from the terminal is very simple:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.