Since XLISP was created to provide a simple basis for experimenting with object-oriented programming, one of the primitive data types included is object. In XLISP, an object consists of a data structure containing a pointer to the object's class as well as an array containing the values of the object's instance variables.
Officially, there is no way to see inside an object [look at the values of its instance variables]. The only way to communicate with an object is by sending it a message.
You can send a message to an object using the send function. This function takes the object as its first argument, the message selector as its second argument [which must be a symbol] and the message arguments as its remaining arguments.
The send function determines the class of the receiving object and attempts to find a method corresponding to the message selector in the set of messages defined for that class. If the message is not found in the object's class and the class has a super-class, the search continues by looking at the messages defined for the super-class. This process continues from one super-class to the next until a method for the message is found. If no method is found, an error occurs.
When a method is found, the evaluator binds the receiving object to the symbol self and evaluates the method using the remaining elements of the original list as arguments to the method. These arguments are always evaluated prior to being bound to their corresponding formal arguments. The result of evaluating the method becomes the result of the expression.
Within the body of a method, a message can be sent to the current object by calling:
(send self ... )
The method lookup starts with the object's class regardless of the class containing the current method.
Sometimes it is desirable to invoke a general method in a superclass even when it is overridden by a more specific method in a subclass. This can be accomplished by calling send-super, which begins the method lookup in the superclass of the class defining the current method rather than in the class of the current object.
The send-super function takes a selector as its first argument [which must be a symbol] and the message arguments as its remaining arguments. Notice that send-super can only be sent from within a method, and the target of the message is always the current object self.
(send-super ... )
is similar to:
(send self ... )
except that method lookup begins in the superclass of the class containing the current method rather than the class of the current object.
object - the top of the class hierarchy.
class - class of all object classes (including itself)
When a new instance of a class is created by sending the message :new to an existing class, the message :isnew followed by whatever parameters were passed to the :new message is sent to the newly created object.
When a new class is created by sending the :new message to the object class, an optional parameter may be specified indicating the superclass of the new class. If this parameter is omitted, the new class will be a subclass of object. A class inherits all instance variables, class variables, and methods from its superclass.