Objects and messages
In scripts, everything is an object except variables, which are pointers to objects. Objects contain data and functions. The data that an object contains are called instance variables, and the functions are called methods.
Objects interact by sending messages to each other. A message is composed of:
• A receiver, which is the object to which the message is sent
• A selector, which gives the name of the method that runs when the message is received
• Optional arguments, which are objects passed as inputs to the script
A message is a request for an object to do something. The object answers the request by running one of its scripts and then returning the answer. The following is a very simple script that sends one message:
bankAccount getBalance.
This message asks the object bankAccount to answer what its balance is.
Even simple arithmetic expressions are really objects and messages. For example, in
tip := bill * 0.15.
bill is the receiver, * is the selector, and 0.15 is the argument. The result of this message is an object that gets stored in tip.
Last modified date: 01/29/2015