KnowledgeWorks and Prolog User Guide > 6 Advanced Topics > 6.3 Use of Meta-Classes

NextPrevUpTopContentsIndex

6.3.1 Example

A meta-class standard-kb-class could be defined as a KnowledgeWorks class. New KnowledgeWorks classes (or even ordinary non-KnowledgeWorks classes) could be defined with this meta-class. KnowledgeWorks could then reason about the instances of the classes and about the class objects themselves. The code below implements this:

(def-kb-class standard-kb-class (standard-class) ())
(defmethod validate-superclass 
           ((class standard-kb-class)
            (superclass standard-class))
           t)
(def-kb-class foo () ((slot))
                    (:metaclass standard-kb-class))

Then when the following rule fires:

(defrule find-kb-class :forward
  (standard-kb-class ? clos::name ?n)
  -->
  ((format t "~%I can reason about class ~s" ?n)))

it will output:

I can reason about class FOO
KnowledgeWorks and Prolog User Guide (Unix version) - 22 Dec 2009

NextPrevUpTopContentsIndex