All Manuals > KnowledgeWorks and Prolog User Guide > 6 Advanced Topics

6.3 Use of Meta-Classes

Objects of meta-classes other than standard-class may be made available to KnowledgeWorks by including the KnowledgeWorks mixin standard-kb-object. This requires:

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 (Windows version) - 01 Dec 2021 19:36:03