Class definition

A new classclass is defined with the define-classdefine-class macro. The syntax of define-class is close to CLOS defclass:


\begin{scheme}
(define-class \var{class} (\hyperi{superclass} \hyperii{superclas...
...cription} \hyperii{slot description}...)
\hyper{metaclass option})
\end{scheme}

The metaclass option will not be discussed in this appendix. The superclasses list specifies the super classes of class (see [*] for more details). A slot description gives the name of a slotslot and, eventually, some ``properties'' of this slot (such as its initial value, the function which permit to access its value, ...). Slot descriptions will be discussed in [*].

As an exemple, consider now that we have to define a complex number. This can be done with the following class definition:


\begin{scheme}
(define-class <complex> (<number>)
(r i))
\end{scheme}

This binds the symbol <complex> to a new class whose instances contain two slots. These slots are called r an i and we suppose here that they contain respectively the real part and the imaginary part of a complex number. Note that this class inherits from <number> which is a pre-defined class (<number> is the super class of the <real> and <integer> pre-defined classes).[*].