Next: , Previous: , Up: mpg-bpr   [Contents][Index]


11.3.124 module/[2,3]   declaration

Synopsis

:- module(+ModuleName, +PublicPred).

:- module(+ModuleName, +PublicPred, +Options).

Declares the file in which the declaration appears to be a module file named ModuleName, with public predicates PublicPred. Must appear as the first term in the file.

Arguments

ModuleName

atom, must be nonvar

PublicPred

list of simple_pred_spec, must be ground

List of predicate specifications of the form Name/Arity.

Options

list of term, must be ground

A list of zero or more options of the form:

hidden(Boolean)

Boolean is false (the default) or true. In the latter case, tracing of the predicates of the module is disabled (although spypoints can be set), and no source information is generated at compile time.

Description

The definition of a module is not limited to a single file, because a module file may contain commands to load other files. If myfile, a module file for ModuleName, contains an embedded command to load yourfile and if yourfile is not itself a module file, then all the predicates in yourfile are loaded into module ModuleName.

Exceptions

Exceptions in the context of loading code are printed as error messages.

instantiation_error

Declaration not ground.

type_error

An argument has the wrong type.

domain_error

Some arity is an integer < 0, or invalid option given.

representation_error

Some arity is an integer > 255.

context_error

Declaration appeared in a goal, or not first in the file being loaded.

permission_error

Declaration appeared as a clause.

Examples

A module declaration from the Prolog library:

:- module(varnumbers, [
        numbervars/1,
        varnumbers/2,
        varnumbers/3
          ],[
        hidden(true)
   ]).

See Also

Module Declarations, ref-mod.



Send feedback on this subject.