Next: 3.5 Standard Predicates in
Up: 3.4 The Module System
Previous: 3.4 The Module System
Contents
Index
The import and export statements of a module
are used by the
compiler for inferring usage of predicates. At compilation time, if a
predicate
occurs as callable in the body of a clause defined in
, but
is neither defined in
nor imported into
from some
other module, a warning is issued that
is undefined. Here
``occurs as callable'' means that
is found as a literal in the
body of a clause, or within a system meta-predicate, such as assert/1, findall/3, etc. Currently, occurrences of a term
inside user-defined meta-predicates are not considered as callable by
XSB's usage inference algorithm. Alternatively, if
is defined in
, it is used if
is exported by
, or if
occurs
as callable in a clause for a predicate that is used in
. The
compiler issues warnings about all unused predicates in a module. On
the other hand, since all modules are compiled separately, the usage
inference algorithm has no way of checking whether a predicate
imported from a given module is actually exported by that module.
Usage inference can be highly useful during code development for
ensuring that all predicates are defined within a set of files, for
eliminating dead code, etc. In addition, import and export
declarations are used by the xsbdoc documentation system to
generate manuals for code 3.5. For these
reasons, it is sometimes the case that usage inference is desired even
in situations where a given file is not ready to be made into a
module, or it is not appropriate for the file to be a module for some
other reason. In such a case the directives document_export/1
and document_import/1 can be used, and have the same syntax as
export/1 and import/1, respectively. These directives
affect only usage inference and xsbdoc. A file is treated as a
module if and only if it includes an export/1 statement, and
only import/1 statements affect dynamic loading and name
resolution for predicates.
Next: 3.5 Standard Predicates in
Up: 3.4 The Module System
Previous: 3.4 The Module System
Contents
Index
Terrance Swift
2007-10-05