Message passing differs from a simple function call:
-
message always transmitted to specific instance- receiver
-
Instance's class decides particular method invoked
-
when method invoked , receiver passed as implicit extra
parameter
-
Receiver accessible using psuedo-variables self
in smalltalk Object pascal, this in C++
and java.
Message Passing Syntax
Two major forms -receiver, then either period or space, ten
arguments:
aCard.flip( );
aCard.includes( a , b );
aCard flip.
aCard includes: a and b.
Operators as Messages
-
smalltalk and C++ operators
can be defined as methods.
- left argument is receive
- right argument is method's parameter
a +
b
-
Java does not support "operator overloading"