;; the following illustrates the definition of CLOS classes for use in ;; the system. Note that the classes are subordinates of the ;; previously defined RBR-object class. ; note new function defRBRclass should be used here when written (defclass train (RBR-object) ((place :accessor place :initarg :place :initform 'unknown) (in-motion :accessor in-motion :initarg :in-motion :initform 'unknown))) (defclass signal (RBR-object) ((place :initform 'unknown :initarg :place :accessor place ) (color :initform 'unknown :initarg :color :accessor color ))) ;; one can have a file of such calls and simple load it or evaluate ;; a set of selected instances directly. Alternatively, one ;; can setf a list of such calls to a name, then mapcar #'eval ;; over that list. It would be useful to write a top level function ;; to do that. The following illustrates a temporary function that ;; is useful for developing the system. (defun test-setup (OB) (clear-RBR) (mapcar #'eval OB)) (setf testOB '( (make-RBR-instance 'train :place 4 :in-motion 'yes :name 1 ) ;note slot and accessor inherited from RBR-object (make-RBR-instance 'train :place 5 :in-motion 'no :name 2) (make-RBR-instance 'train :place 2 :in-motion 'yes :name 3) (make-RBR-instance 'signal :place 5 :color 'green :name 1 ) ;no confusion re name conflict, ;this is an object of different type (make-RBR-instance 'signal :place 8 :color 'red :name 2 ) (make-RBR-instance 'signal :place 3 :color 'green :name 3 ) )) ;; Note the distinction between this and *RB*. Each expression here is ;; a function call to make-RBR-instance, where as each rule in ;; *RB* is just a list structure. The calls to make-RBR-instance ;; push the created CLOS instances onto a list which is the ;; value of *OB*. The rules could be handled in a similar way, ;; with the various parts of each rule placed on slots of a CLOS ;; class defined for that purpose. ;; the following sets *OB* using the temporary setup function defined ;; above. (test-setup testOB)