11.3.119 (multifile)/1 [ISO,declaration]

Synopsis

:- multifile +PredSpecs

Declares the clauses of the predicates defined by PredSpecs to be multifile in the source file (suppresses compile-time warnings).

Arguments

:PredSpecs
pred_spec_forest, must be ground

A predicate specification, or a list of such, or a sequence of such separated by commas.

Description

By default, all clauses for a predicate are expected to come from just one file. This assists with reloading and debugging of code. Declaring a predicate multifile means that its clauses can be spread across several different files. This is independent of whether or not the predicate is declared dynamic.

Should precede all the clauses for the specified predicates in the file.

There should be a multifile declaration for a predicate P in every file that contains clauses for P. If a multifile predicate is dynamic, there should be a dynamic declaration in every file containing clauses for the predicate.

When a file containing clauses for a multifile predicate (P) is reloaded, the clauses for P that previously came from that file are removed. Then the new clauses for P (which may be the same as the old ones) are added to the end of the definition of the multifile predicate.

If a multifile declaration is found for a predicate that has already been defined in another file (without a multifile declaration), then this is considered to be a redefinition of that predicate. Normally this will result in a multiple-definition style-check warning (see style_check/1).

The predicate source_file/2 can be used to find all the files containing clauses for a multifile predicate.

Exceptions

instantiation_error
PredSpecs not ground.
type_error
Either name or arity in PredSpec has the wrong type
domain_error
Arity not in the range 0..255.
context_error
“declaration appeared in query”, or TODO: declaration appears other than as the first term in a file being loaded.

See Also

Multifile Declarations.


Send feedback on this subject.