next up previous

10.2 SPECIFYING A CONSTRUCT'S MODULE

The module in which a constructs is placed can be specified when the construct is defined. The deffacts, deftemplate, defrule, deffunction, defgeneric, defclass, and definstances constructs all specify the module for the construct by including it as part of the name. The module of a defglobal construct is indicated by specifying the module name after the defglobal keyword. The module of a defmessage-handler is specified as part of the class specifier. The module of a defmethod is specified as part of the generic function specifier. For example, the following constructs would be placed in the DETECTION module. (defrule DETECTION::Find-Fault (sensor (name ?name) (value bad)) => (assert (fault (name ?name)))) (defglobal DETECTION ?*count* = 0) (defmessage-handler DETECTION::COMPONENT get-charge () (* ?self:flux ?self:flow)) (defmethod DETECTION::+ ((?x STRING) (?y STRING)) (str-cat ?x ?y))

Example

CLIPS> (clear)
CLIPS> (defmodule A)
CLIPS> (defmodule B)
CLIPS> (defrule foo =>)
CLIPS> (defrule A::bar =>)
CLIPS> (list-defrules)
bar
For a total of 1 defrule.
CLIPS> (set-current-module B)
A
CLIPS> (list-defrules)
foo
For a total of 1 defrule.
CLIPS>


next up previous