11.3.50 current_module/[1,2]

Synopsis

current_module(?ModuleName)

Queries whether a module is “current” or backtracks through all of the current modules.

current_module(?ModuleName, ?AbsFile)

Associates modules with their module-files.

Arguments

ModuleName
atom
AbsFile
atom

Absolute filename in which the module is defined.

Description

A loaded module becomes “current” as soon as some predicate is defined in it, and a module can never lose the property of being current.

It is possible for a current module to have no associated file, in which case current_module/1 will succeed on it but current_module/2 will fail. This arises for the special module user and for dynamically-created modules (see ref-mod).

If its arguments are not correct, or if Module has no associated file, current_module/2 simply fails.

Backtracking

current_module/1 backtracks through all of the current modules. The following command will print out all current modules:

     | ?- current_module(Module), writeq(Module), nl, fail.

current_module/2 backtracks through all of the current modules and their associated files.

Exceptions

type_error

Examples

     | ?- findall(M,current_module(M),Ms).
     Ms = [chr,user,prolog,'SU_messages',clpfd] ?
     yes
     | ?- findall(M-F,current_module(M,F),MFs).
     MFs = ['SU_messages'-'/src/sicstus/matsc/sicstus4/Utils/x86-linux-glibc2.3/bin/sp-4.1.0beta1/sicstus-4.1.0beta1/library/SU_messages.pl'] ?
     yes

See Also

ref-mod-ilm.


Send feedback on this subject.