:- 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, then 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, then the old clauses from the same file are removed. The new clauses are added at the end. Please note: if the file being reloaded is a module-file, however, then all predicates belonging to the module are abolished, including any multifile predicate.
If a multifile predicate is loaded from a file with no multifile declaration for it, then 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, then it must also be done so in the other files from which it is loaded. See mpg-ref-multifile.