KnowledgeWorks and Prolog User Guide > 4 Objects > 4.1 CLOS objects > 4.1.2 Named Classes

NextPrevUpTopContentsIndex

4.1.2.1 Examples

(def-named-kb-class truck ()
     ((location :initarg :location)
      (destination :initarg :destination)))
(make-instance 'truck 
               :kb-name 'ford1
               :location 'cambridge)

creates the instance #<KB-OBJECT FORD1> .

(make-instance 'truck :location 'london)

creates the instance #<KB-OBJECT TRUCK123> , and

(get-kb-object 'ford1)

returns #<KB-OBJECT FORD1> and

(kb-name (get-kb-object 'ford1))

returns FORD1 . The class definition

(defclass truck (named-kb-object) ...)

would have been identical except that the second truck would have been given a name such as OBJECT345 rather than TRUCK123 (as def-named-kb-class overrides the inherited initform for the kb-name slot (gentemp "OBJECT") with a more specific one (gentemp <class-name>) ).


KnowledgeWorks and Prolog User Guide (Unix version) - 22 Dec 2009

NextPrevUpTopContentsIndex