In EuLisp, every object in the system has a specific class. Classes themselves
are first-class objects. In this respect EuLisp differs from statically-typed
object-oriented languages such as C++ and microCEYX. The EuLisp object
system is called Telos. The facilities of the object system are split across the
two levels of the definition. Level-0 supports the definition of generic
functions, methods and structures. The defined name of this module is
telos0.
Programs written using Telos typically involve the design of a class
hierarchy, where each class represents a category of entities in the
problem domain, and a protocol, which defines the operations on
the objects in the problem domain.
A class defines the structure and behaviour of its instances.
Structure is the information contained in the class's instances and
behaviour is the way in which the instances are treated by the
protocol defined for them.
The components of an object are called its slots. Each slot of an
object is defined by its class.
A protocol defines the operations which can be applied to instances of a set of
classes. This protocol is typically defined in terms of a set of generic
functions, which are functions whose application behaviour depends on
the classes of the arguments. The particular class-specific behaviour is
partitioned into separate units called methods. A method is not a
function itself, but is a closed expression which is a component of a generic
function.
Generic functions replace the send construct found in many
object-oriented languages. In contrast to sending a message to a particular
object, which it must know how to handle, the method executed by a generic
function is determined by all of its arguments. Methods which specialize on
more than one of their arguments are called multi-methods.
Inheritance is provided through classes. Slots and methods defined
for a class will also be defined for its subclasses but a subclass may specialize
them. In practice, this means that an instance of a class will contain all the
slots defined directly in the class as well as all of those defined in the class's
superclasses. In addition, a method specialized on a particular class will be
applicable to direct and indirect instances of this class. The inheritance rules,
the applicability of methods and the generic dispatch are described in detail
later in this section.
Classes are defined using the defclass () and
defcondition (?? ) defining forms, both of which create
top-lexical bindings.
Generic functions are defined using the defgeneric defining
form, which creates a named generic function in the top-lexical environment of
the module in which it appears and generic-lambda, which
creates an anonymous generic function. These forms are described in detail
later in this section.
Methods can either be defined at the same time as the generic function, or else
defined separately using the defmethod macro, which adds a
new method to an existing generic function. This macro is described in detail
later in this section.
System Defined Classes
The basic classes of EuLisp are elements of the object system class hierarchy,
which is shown in Figure ?? . Indentation indicates a subclass relationship to
the class under which the line has been indented, for example,
<condition> is a subclass of <object>. The
names given here correspond to the bindings of names to classes as they are
exported from the level-0 modules. Classes directly relevant to the object
system are described in this section while others are described in corresponding
sections, e.g. <condition> is described in Section ?? .
Julian Padget, jap@maths.bath.ac.uk, this version February 27, 1995