next up previous

10.1 DEFINING MODULES

Modules are defined using the defmodule construct.

Syntax

(defmodule <module-name> [<comment>] 
   <port-spec>*)
<port-specification> ::= (export <port-item>) |
                         (import <module-name> <port-item>)
                
<port-item>          ::= ?ALL |
                         ?NONE |
                         <port-construct> ?ALL |
                         <port-construct> ?NONE |
                         <port-construct> <construct-name>+ 
<port-construct>     ::= deftemplate | defclass |
                         defglobal | deffunction |
                         defgeneric

A defmodule cannot be redefined or even deleted once it is defined (with the exception of the MAIN module which can be redefined once). The only way to delete a module is with the clear command. Upon startup and after a clear command, CLIPS automatically constructs the following defmodule.

(defmodule MAIN)

All of the predefined system classes (see section 9.2) belong to the MAIN module. However, it is not necessary to import or export the system classes; they are always in scope. Discounting the previous exception, the predefined MAIN module does not import or export any constructs. However, unlike other modules, the MAIN module can be redefined once after startup or a clear command.

Example

(defmodule FOO
   (import BAR ?ALL)
   (import YAK deftemplate ?ALL)
   (import GOZ defglobal x y z)
   (export defgeneric +)
   (export defclass ?ALL))


next up previous