Quintus Prolog Manual


(PREV) (NEXT)

g-10: Looking at the Program State

g-10-0: Overview

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 {manual(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 {manual(l-3)}), 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: Prolog Flags

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:

Flag
Purpose
character_escapes
Enable or disable escaping of special characters in I/O operations. (See {manual(g-1-3)})
debugging
Turn on/off trace and debug mode by using prolog_flag/3 or by using the predicates trace/0, debug/0, notrace/0, and nodebug/0.
fileerrors
Set or reset the fileerrors flag by using prolog_flag/3 or by using the pair of predicates fileerrors/0 and nofileerrors/0.
gc
Turn on/off garbage collection by using prolog_flag/3 or by using the predicates gc/0 and nogc/0.
gc_margin
Set the number of bytes that must be reclaimed by a garbage collection in order to avoid heap expansion (not available on some systems; see {manual(g-12)})
gc_trace
Enable or disable diagnostic tracing of garbage collections.
multiple
on or off.
single_var
on or off.
syntax_error
Control Prolog's response to syntax errors. See {manual(g-19-4-10)}.
unknown
Set the action to be taken on unknown procedures by using prolog_flag/3 or unknown/2 (see {manual(e-1-4-4)}). unknown/2 writes a message to 'user_output' saying what the new state is. It is intended for use at the top level. prolog_flag/3 does not write a message. It is intended for use in code.

For further details, see the reference page. Also see {manual(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:

Flag
Purpose
add_ons
What add-on products are statically linked into to Prolog system?
host_type
What is the host-type?
quintus_directory
What is the absolute path of the Quintus directory, where is the root of the entire Quintus Installation hierarchy?
runtime_directory
What is the absolute path of the directory where all Prolog executables reside? In the Runtime System, it is expected that this value will be overwritten, using qsetpath when the runtime system is installed (see 'man qsetpath' and 'man qgetpath'). This flag is used to define file_search_path(runtime,RuntimeDir).
version
What version of Prolog is being run?
system_type
development

Use prolog_flag/2 to make queries, prolog_flag/3 to make changes.

g-10-4: Load Context

By calling prolog_load_context/[2,3] you can determine:

g-10-4-1: Predicate Summary


Copyright (C) 1997 AI International Ltd
contact: product support sales information