Historically, LISP first introduced structures (a kind of records), through the defstruct macro. Until then, LISPers used to implement specialized structures as lists of specific length, defining slot accessors as functions with meaningful names, such as person-name, person-age, person-sex, rather than using meaningless functions such as car, cadr, caddr. They eventually defined a defstruct macro providing the automatic generation of a constructor and accessors. Today, defstruct is considered as a little outdated: it is superseded by CLOS.
The Common LISP Object System is a very sophisticated object oriented programming language, featuring multiple inheritance, multi methods, and complex schemes for combining methods. Method definition applies to basic types (such as numbers, strings or lists) considered as classes, as well as user defined classes. CLOS is certainly too rich for practical purposes.
This is a very tiny subset of CLOS, featuring
The defcl module thus only deals with classes and objects, not with methods.
Remark: regarding Flow Game project, students are invited to stick to classical functional programming, augmented with defcl objects and classes, and discard method definition tools (defmethod and defgeneric), with the exception of print-object methods, which are extremely useful for debugging purposes (see Tulisp example).
Downloading and Playing with defcl.lisp Module Source File
You can download the defcl.lisp module, also available on ENSEIRB-MATMECA servers, see
to play with it, and evaluate the commented out examples.
Using Compiled defcl Module from its Installation Directory
You can use the compiled version of defcl directly from its Tulisp installation directory (without copying anything). Assuming your project directory is <student-project>, add symbolic links to Tulisp installation directory and sbcl.lisp module:
You should insert LISP directives for loading defcl at the beginning of your LISP module, right after the in-package declaration (normally the first form in your LISP file):
(eval-when (:compile-toplevel :load-toplevel :execute) (require "SBCL" "sbcl")) ; boot strap! (eval-when (:compile-toplevel :load-toplevel :execute) (with-application-directory (:RELATIVE "tulisp") ; directory location. (sbcl-require "DEFCL" "defcl"))) ; require defcl.