Defining a Module

The normal way to define a module is by creating a module-file for it and loading it into the Prolog system. A module-file is a Prolog file that begins with a module declaration.

A module declaration has the form

     :- module(+ModuleName, +PublicPredList).
     

Such a declaration must appear as the first term in a file, and declares that file to be a module-file. The predicates in the file will become part of the module ModuleName, and the predicates specified in PublicPredList are those that can be imported by other modules; that is, the public predicates of this module.

Instead of creating and loading a module-file, it is also possible to define a module dynamically by, for example, asserting clauses into a specified module. A module created in this way has no public predicates; all its predicates are private. This means that they cannot be called from outside that module except by explicitly overriding the modularity rules as described in ref-mod-vis. Dynamic creation of modules is described in more detail in ref-mod-dmo.