[Up] [Contents] [Index] [Summary]

4.6.2 Overruling Module Boundaries

The mechanism above is sufficient to create an acceptable module system. There are however cases in which we would like to be able to overrule this schema and explicitly call a predicate in some module or assert explicitly in some module. The first is useful to invoke goals in some module from the user's toplevel or to implement a object-oriented system (see above). The latter is useful to create and modify dynamic modules (see section 4.7).

For this purpose, the reserved term :/2 has been introduced. All built-in predicates that transform a term into a predicate reference will check whether this term is of the form `<Module>:<Term>' . If so, the predicate is searched for in Module instead of the goal's context module. The : operator may be nested, in which case the inner-most module is used.

The special calling construct <Module>:<Goal> pretends Goal is called from Module instead of the context module. Examples:

?- assert(world:done). % asserts done/0 into module world ?- world:assert(done). % the same ?- world:done. % calls done/0 in module world