type: object location: built-in source file: xlobj.c Common LISP compatible: no supported on: all machines
CLASS is the built-in object class that is used to build other classes. Classes are, essentially, the template for defining object instances.
(setq myclass (send class :new '(var))) ; create MYCLASS with VAR (send myclass :answer :isnew '() ; set up initialization '((setq var nil) self)) (send myclass :answer :set-it '(value) ; create :SET-IT message '((setq var value))) (setq my-obj (send myclass :new)) ; create MY-OBJ of MYCLASS (send my-obj :set-it 5) ; VAR is set to 5
CLASS DEFINITION: The internal definition of the CLASS object instance looks like:
Object is #<Object: #23fe2>, Class is #<Object: #23fe2> MESSAGES = ((:ANSWER . #<Subr-: #23e48>) (:ISNEW . #<Subr-: #23e84>) (:NEW . #<Subr-: #23ea2>)) IVARS = (MESSAGES IVARS CVARS CVALS SUPERCLASS IVARCNT IVARTOTAL) CVARS = NIL CVALS = NIL SUPERCLASS = #<Object: #23fd8> IVARCNT = 7 IVARTOTAL = 7 #<Object: #23fe2>
The class of CLASS is CLASS, itself. The superclass of CLASS is OBJECT. Remember that the location information (like #23fe2) varies from system to system, yours will probably look different.
BUILT-IN METHODS: The built in methods in XLISP include:
<message> operation ------------------------------------------------------- :ANSWER Add a method to an object. :CLASS Return the object's class. :ISNEW Run initialization code on object. :NEW Create a new object (instance or class). :SHOW Show the internal state of the object.
MESSAGE STRUCTURE: The normal XLISP convention for a <message> is to have a valid symbol preceeded by a colon like :ISNEW or :MY-MESSAGE. However, it is possible to define a <message> that is a symbol without a colon, but this makes the code less readable.