Home Contents Index Summary Previous Next

5.8 Module Handling Predicates

This section gives the predicate definitions for the remaining built-in predicates that handle modules.

module(+Module, +PublicList)
This directive can only be used as the first term of a source file. It declares the file to be a module file, defining Module and exporting the predicates of PublicList. PublicList is a list of name/arity pairs.

module_transparent +Preds
Preds is a comma separated list of name/arity pairs (like dynamic/1). Each goal associated with a transparent declared predicate will inherit the context module from its parent goal.

meta_predicate +Heads
This predicate is defined in library(quintus) and provides a partial emulation of the Quintus predicate. See section 5.9.1 for details.

current_module(-Module)
Generates all currently known modules.

current_module(?Module, ?File)
Is true if File is the file from which Module was loaded. File is the internal canonical filename. See also source_file/[1,2].

context_module(-Module)
Unify Module with the context module of the current goal. context_module/1 itself is transparent.

export(+Head)
Add a predicate to the public list of the context module. This implies the predicate will be imported into another module if this module is imported with use_module/[1,2]. Note that predicates are normally exported using the directive module/2. export/1 is meant to handle export from dynamically created modules.

export_list(+Module, ?Exports)
Unifies Exports with a list of terms. Each term has the name and arity of a public predicate of Module. The order of the terms in Exports is not defined. See also predicate_property/2.

import_module(+Module, -Import)
True if Import is defined as an import module for Module. All normal modules only import from user, which imports from system. The predicates add_import_module/3 and delete_import_module/2 can be used to manipulate the import list.

add_import_module(+Module, +Import, +StartOrEnd)
If Import is not already an import module for Module, add it to this list at the start or end depending on StartOrEnd. See also import_module/2 and delete_import_module/2.

delete_import_module(+Module, +Import)
Delete Import from the list of import modules for Module. Fails silently if Import is not in the list.

default_module(+Module, -Default)
Succesively unifies Default with the module names from which a call in Module attempts to use the definition. For the module user, this will generate user and system. For any other module, this will generate the module itself, followed by user and system.

Backward compatibility. New code should use import_module/2.

module(+Module)
The call module(Module) may be used to switch the default working module for the interactive toplevel (see prolog/0). This may be used to when debugging a module. The example below lists the clauses of file_of_label/2 in the module tex.


1 ?- module(tex).

Yes
tex: 2 ?- listing(file_of_label/2).
...