Quintus Prolog Manual
G-10: Looking at the Program State
Various aspects of the program state can be inspected: The clauses of all or selected dynamic procedures, currently available atoms, user defined predicates, source files of predicates and clauses, predicate properties and the current load context can all be accessed by calling the predicates listed in section G-10. Furthermore, the values of prolog flags can be inspected and, where it makes sense, changed. The following predicates accomplish these tasks:
G-10-1: Associating Predicates with their Properties
The following properties are associated with predicates either implicitly or by declaration:
built-in foreign multifile checking_advice has_advice spied compiled imported_from volatile dynamic interpreted exported locked extern_link meta_predicate
These are described elsewhere in the manual (see Index). To query these associations, use predicate_property/2. The reference page contains several examples.
G-10-2: Associating Predicates with Files
Information about loaded files and the predicates and clauses in them is returned by source_file/[1,2,3]. source_file/1 can be used to identify an absolute file name as loaded, or to backtrack through all loaded files. To find out the correlation between loaded files and predicates, call source_file/2. source_file/3 allows for querying about which clause for a predicate is in which loaded file. source_file/3 is useful for handling multifile predicates (see section L-3-105), but it works for predicates defined completely in one file, as well.
Any combination of bound and unbound arguments is possible, and source_file/3 will generate the others.
G-10-3-1: Changing or Querying System Parameters
Prolog flags enable you to modify certain aspects of Prolog's behavior, as outlined below. This is accomplished by using prolog_flag/3. If you simply want to query the value of a flag, use prolog_flag/2.
By using the prolog flags listed below, it is possible to:
For further details, see the reference page. Also see Chapter G-12 for more detailed descriptions of the garbage collection flags.
To inspect the value of a flag without changing it, one can say
| ?- prolog_flag(FlagName, Value).
You can use prolog_flag/2 to enumerate all the FlagNames which the system currently understands, together with their current values.
G-10-3-2: Parameters which can be Queried Only
Prolog flags can be used to effect the changes listed above, or to ask about the current values of those parameters. In addition, you can use prolog_flag/2 (not prolog_flag/3) to make the following queries using the flag names listed below:
Use prolog_flag/2 to make queries, prolog_flag/3 to make changes.
Figure G-10-1: Load Context
By calling prolog_load_context/[2,3] you can determine:
current_atom/1 prolog_flag/[2,3] current_predicate/2 prolog_load_context/2 listing/[0,1] source_file/[1,2,3] predicate_property/2
contact:
product support
sales information