The Receiver Variable

Once a message has been accepted by a receiver, a method will be invoked and executed. Inside the method, the receiver for the message can be accessed by means of a pseudo-variable, a variable that does not require a declaration. This pseudo-variable goes by different names in different languages. It is named this in Java, C++, C# and some other languages. It is named self in Smalltalk, Objective-C, Object Pascal. It is named current in Eiffel.

The receiver variable can be used to make explicit references to data fields and methods in the current object. In some languages this explicit referincing is required. In other Object-Oriented languages, it is implicit. That is, a reference to a data field or a method that does not have an explicit reciver will implicitly be assumed to refer to the current object.

[audio] [real] Text to accompany slidexx, in Chapter 5 of An Introduction to Object-Oriented Programming