next up previous

10.3 SPECIFYING MODULES

Commands such as undefrule and ppdefrule require the name of a construct on which to operate. In previous versions of CLIPS, constructs were always referred to by their name only, so it was sufficient just to pass the name of the construct to these commands. With modules, however, it is possible to have a construct with the same name in two different modules. The modules associated with a name can be specified either explicitly or implicitly. To explicitly specify a nameís module the module name (a symbol) is listed followed by two colons, ::, and then the name is listed. The module name followed by :: is referred to as a module specifier. For example, MAIN::findstuff, refers to the findstuff construct in the MAIN module. A module can also be implicitly specified since there is always a ìcurrentî module. The current module is changed whenever a defmodule construct is defined or the setcurrentmodule function is used. The MAIN module is automatically defined by CLIPS and by default is the current module when CLIPS is started or after a clear command is issued. Thus the name findstuff would implicitly have the MAIN module as its module when CLIPS is first started.

CLIPS> (clear)
CLIPS> (defmodule A)
CLIPS> (defglobal A ?*x* = 0)
CLIPS> (defmodule B)
CLIPS> (defglobal B ?*y* = 1)
CLIPS> (ppdefglobal y)
(defglobal B ?*y* = 1)
CLIPS> (ppdefglobal B::y)
(defglobal B ?*y* = 1)
CLIPS> (ppdefglobal x)
[PRNTUTIL1] Unable to find defglobal x
CLIPS> (ppdefglobal A::x)
(defglobal A ?*x* = 0)
CLIPS>


next up previous