4.3.4.1 Multifile Declarations

A declaration

     :- multifile :PredSpec, ..., :PredSpec.  ISO

where each PredSpec is a predicate spec, causes the specified predicates to become multifile. This means that if more clauses are subsequently loaded from other files for the same predicate, the new clauses will not replace the old ones, but will be added at the end instead.

An example where multifile declarations are particularly useful is in defining hook predicates. A hook predicate is a user-defined predicate that somehow alters or customizes the behavior of SICStus Prolog. A number of such hook predicates are described in this manual. See also ref-sem-typ-hok. Hook predicates should always be declared as multifile, as this is the convention followed in the library modules.

Multifile declarations must precede any other declarations for the same predicate(s)!

If a file containing clauses for a multifile predicate is reloaded, the old clauses from the same file are removed. The new clauses are added at the end.

If a multifile predicate is loaded from a file with no multifile declaration for it, the predicate is redefined as if it were an ordinary predicate (i.e. the user is asked for confirmation).

If a multifile predicate is declared dynamic in one file, it must also be done so in the other files from which it is loaded.


Send feedback on this subject.