Quintus
Prolog Manual
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:
- listing list all dynamic procedures in the type-in module
- listing(P) list the dynamic procedure(s) specified by P
- current_atom(A) A is a currently available atom (nondeterminate)
- current_predicate(A,P) A is the name of a predicate with most
general goal P (nondeterminate)
- predicate_property(P,Prop) Prop is a property of the loaded
predicate P (nondeterminate)
- prolog_flag(F,V) V is the current value of Prolog flag F (nondeterminate)
- prolog_flag(F,O,N) O is the old value of Prolog flag F; N
is the new value
- prolog_load_context(K,V) find out the context of the current
load
- source_file(F) F is a source file which has been loaded into
the data base
- source_file(P,F) P is a predicate defined in the loaded file
F
- source_file(P,F,N) Clause number N of predicate P came from
file F
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:
- whether the current context is in a loading/compilation or a start-up
of an application.
- the current Prolog load/compilation context: module, file, directory
or stream.
g-10-4-1: Predicate Summary
- 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
Copyright (C) 1997 AI International
Ltd
contact: product
support sales information