4.9.5 Load Context

When a Prolog source file is being read in, some aspects of the load context can be accessed by the built-in predicate prolog_load_context/2, which accesses the value of a given key. The available keys are:

source
The absolute path name of the file being compiled. During loading of a PO file, the corresponding source file name is returned.
file
Outside included files (see Include Declarations) this is the same as the source key. In included files this is the absolute path name of the file being included.
directory
The absolute path name of the directory of the file being compiled/loaded. In included files this is the directory of the file being included.
module
The source module (see ref-mod-mne). This is useful for example if you are defining clauses for user:term_expansion/6 and need to access the source module at compile time.
stream
The stream being compiled or loaded from.
term_position
A term representing the stream position of the last clause read.

Send feedback on this subject.