[ Predicate Database and Compiler | Reference Manual | Alphabetic Index ]

current_pragma(?Pragma)

Retrieves pragmas that are currently in effect for the context module
Pragma
A variable, atom or compound term

Description

Used to test or enumerate currently set pragmas in the context module. This is typically only meaningful during the compilation process or during some other kind of source processing.

Source processing tools (or code invoked from source-processing tools, e.g. inline-transformations) can exploit the pragma facility to make their behaviour user-configurable. All they need to do is document the pragma names/structures and check for them using current_pragma/1.

Pragma recording works as follows: if the argument of the pragma directive is a structure, the new structure overwrites any previously recorded structure with the same functor. If the argument is an atom, e.g. 'xxx', then a previously recorded atom 'noxxx' is erased and 'xxx' recorded instead, and vice versa.

Modes and Determinism

Modules

This predicate is sensitive to its module context (tool predicate, see @/2).

Exceptions

(5) type error
Pragma is not a variable, atom or compound term.

Examples

    :- pragma(blah).

    ?- findall(P, current_pragma(P), L), writeln(L).
    [blah]

    :- pragma(myoption(on)).

    ?- findall(P, current_pragma(P), L), writeln(L).
    [blah, myoption(on)]

    :- pragma(myoption(off)).

    ?- findall(P, current_pragma(P), L), writeln(L).
    [blah, myoption(off)]

    :- pragma(noblah).

     ?- findall(P, current_pragma(P), L), writeln(L).
    [noblah, myoption(off)]

     ?- current_pragma(myoption(off)).
     Yes.

See Also

compile / 1, inline / 1, inline / 2, pragma / 1, library(source_processor)