The concept of a source module is explained in ref-mod-som. For any goal, the applicable source module is determined when the goal is compiled rather than when it is executed.
A procedure that needs to refer to the source module has arguments designated for module name expansion. These arguments are expanded at compile time by the transformation
X -> M:X
where M is the name of the source module. For example, the goal
call(X)
is expanded into call(M:X)
and the goal
clause(Head, Body)
is expanded into clause(M:Head, Body)
.
Module name expansion is avoided if the argument to be expanded is
already a :/2
term. In this case it is unnecessary since the
module to be used has already been supplied by the programmer.
The built-in predicates that use module name expansion, and the
arguments requiring module name expansion are shown below. These
arguments are labeled [MOD]
in the Arguments field of the
reference page for each.
abolish(M:Pred)
abolish(M:Name, Arity)
assert(M:Term)
assert(M:Term, Ref)
asserta(M:Term)
asserta(M:Term, Ref)
assertz(M:Term)
assertz(M:Term, Ref)
bagof(T, M:P, S)
call(M:Goal)
check_advice(M:ListOfPredSpecs)
clause(M:Head, Body)
clause(M:Head, Body, Ref)
compile(M:Files)
consult(M:Files)
current_advice(M1:Goal, Port, M2:Action)
current_predicate(Name, M:Term)
debugger(Current, M:New)
ensure_loaded(M:Files)
findall(T, M:Pred, List)
initialization(M:Goal)
listing(M:List)
load_files(M:Files)
load_files(M:Files, Options)
load_foreign_files(M:Files, Libs)
multifile_assertz(M:Term)
nocheck_advice(M:ListOfPredSpecs)
nospy(M:List)
phrase(M:Phrase, S0)
phrase(M:Phrase, S0, S)
predicate_property(M:Goal, Property)
remove_advice(M:Goal, Port, Action)
retract(M:Term)
retractall(M:Term)
save_predicates(M:PredSpecs,File)
save_program(File,M:Goal)
setof(T, M:P, S)
source_file(M:Term,File)
source_file(M:PredSpec,ClauseNumber,File)
spy(M:List)
use_module(M:Files)
use_module(M:File, IL)
use_module(ExportModule, M:File, IL)
volatile(M:PredSpec)
X^(M:Goal)
[M:File|Rest]
In all of these predicates, M:
can stand for multiple modules. It
is the innermost module that is used in this case. For example,
call(m1:m2:m3:p)
calls m3:p/0
.