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.
:- 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.