Home
Contents
Index
Summary
Previous
Next
The current system defines 3 different mechanisms to query and/or set
properties of the environment: please/3, flag/3
and feature/2
as well as a number of special purpose predicates of which unknown/2, fileerrors/2
are examples. The ISO standard defines prolog_flag. It is likely that
all these global features will be merged into a single in the future.
- please(+Key, -Old, +New)
-
The predicate please/3 (5)
is a solution to avoid large numbers of environment control predicates.
Later versions will support other environment control as now provided
via the predicates style_check/1, leash/1, unknown/2,
the tracer predicates, etc. These predicates are then moved into a
library for backwards compatibility. The currently available options
are:
- optimise (on/off) Default: off
-
Switch optimise mode for the compiler
on
or off
(see also the command line option -O). Currently
optimise compilation only implies compilation of arithmetic, making it
fast, but invisible to the tracer. Later versions might imply various
other optimisations such as incorporating a number of basic predicates
in the virtual machine (var/1, fail/0,
=/2, etc.) to gain speed at the cost of crippling the debugger. Also
source level optimisations such as integrating small predicates into
their callers, eliminating constant expressions and other predictable
constructs. Source code optimisation is never applied to predicates that
are declared dynamic (see dynamic/1).
- autoload (on/off) Default: on
-
If
on
autoloading of library functions is enabled. If
off
autoloading is disabled. See section
2.9.
- verbose_autoload (on/off) Default: off
-
If
on
the normal consult message will be printed if a
library is autoloaded. By default this message is suppressed. Intended
to be used for debugging purposes (e.g. where does this predicate come
from?).
- feature(?Key, -Value)
-
The predicate feature/2
defines an interface to installation features: options compiled in,
version, home, etc. With both arguments unbound, it will generate all
defined features. With the `Key' instantiated it unify the value of the
feature. Features come in three types: boolean features, features with
an atom value and features with an integer value. A boolean feature is
true iff the feature is present and the Value is
the atom
true
. Currently defined keys:
- arch (atom)
-
Identifier for the hardware and operating system SWI-Prolog is running
on. Used to determine the startup file as well as to select foreign
files for the right architecture. See also load_foreign/5.
- version (integer)
-
The version identifier is an integer with value:
10000 × Major
+ 100 × Minor + Patch
Note that in releases upto 2.7.10 this feature yielded an atom holding
the three numbers separated by dots. The current representation is much
easier for implementing version-conditional statements.
- home (atom)
-
SWI-Prolog's notion of the home-directory. SWI-Prolog uses it's home
directory to find its startup file as
<home>/startup/startup.<arch>
and to find its library as <home>/library
.
- pipe (bool)
-
If true, tell(pipe(command)), etc. are supported.
- load_foreign (bool)
-
If true, load_foreign/[2,5]
are implemented.
- open_shared_object (bool)
-
If true, open_shared_object/2
and friends are implemented, providing access to shared libraries (.so
files). This requires the C-library functions dlopen() and friends as
well as the configuration option
--with-dlopen.
- dynamic_stacks (bool)
-
If true, the system uses some form of `sparse-memory management' to
realise the stacks. If false, malloc()/realloc() are used for the
stacks. In earlier days this had consequenses for foreign code. As of
version 2.5, this is no longer the case.
Systems using `sparse-memory management' are a bit faster as there is
no stack-shifter, and checking the stack-boundary is often realised by
the hardware using a `guard-page'. Also, memory is actually returned to
the system after a garbage collection or call to trim_stacks/0
(called by
prolog/0
after finishing a user-query).
- c_libs (atom)
-
Libraries passed to the C-linker when SWI-Prolog was linked. May be used
to determine the libraries needed to create statically linked extensions
for SWI-Prolog. See section 5.7.
- c_staticlibs (atom)
-
On some machines, the SWI-Prolog executable is dynamically linked, but
requires some libraries to be statically linked. Obsolete.
- c_cc (atom)
-
Name of the C-compiler used to compile SWI-Prolog. Normally either gcc
or cc. See section 5.7.
- c_ldflags (atom)
-
Special linker flags passed to link SWI-Prolog. See section
5.7.
- save (bool)
-
If true, save/[1,2] is
implemented. Saving using save/0 is
obsolete. See
qsave_program/[1,2].
- save_program (bool)
-
If true, save_program/[1,2]
is implemented. Saving using save_program/0
is obsolete. See qsave_program/[1,2].
- readline (bool)
-
If true, SWI-Prolog is linked with the readline library. This is done by
default if you have this library installed on your system. It is also
true for the Win32 plwin.exe version of SWI-Prolog, which realises a
subset of the readline functionality.
- saved_program (bool)
-
If true, Prolog is started from a state saved with qsave_program/[1,2].
- runtime (bool)
-
If true, SWI-Prolog is compiled with -DO_RUNTIME, disabling various
useful development features (currently the tracer and profiler).
- max_integer (integer)
-
Maximum integer value. Most arithmetic operations will automatically
convert to floats if integer values above this are returned.
- min_integer (integer)
-
Minimum integer value.
- max_tagged_integer (integer)
-
Maximum integer value represented as a `tagged' value. Tagged integers
require 4-bytes storage and are used for indexing. Larger integers are
represented as `indirect data' and require 16-bytes on the stacks
(though a copy requires only 4 additional bytes).
- min_tagged_integer (integer)
-
Start of the tagged-integer value range.
- float_format (atom)
-
C printf() format specification used by write/1
and friends to determine how floating point numbers are printed. The
default is %g. May be changed. The specified value is
passed to printf() without further checking. For example, if you want
more digits printed,
%.12g will print all floats using 12 digits instead of the
default 6. See also format/[1,2], write/1, print/1
and portray/1.
- compiled_at (atom)
-
Describes when the system has been compiled. Only available if the
C-compiler used to compile SWI-Prolog provides the __DATE__ and __TIME__
macros.
- character_escapes (bool)
-
If true (default), read/1
interprets
\
escape sequences in quoted atoms and strings.
May be changed.
- allow_variable_name_as_functor (bool)
-
If true (default is false),
Functor(arg)
is read as if it
was written 'Functor'(arg)
. Some applications use the
Prolog read/1
predicate for reading an application defined script language. In these
cases, it is often difficult to explain none-Prolog users of the
application that constants and functions can only start with a lowercase
letter. Variables can be turned into atoms starting with an uppercase
atom by calling read_term/2
using the option variable_names
and binding the variables
to their name. Using this feature, F(x) can be turned into valid syntax
for such script languages. Suggested by Robert van Engelen. SWI-Prolog
specific.
- history (integer)
-
If > 0, support Unix csh(1) like history as
described in
section 2.4. Otherwise, only support reusing
commands through the commandline editor. The default is to set this
feature to 0 if a commandline editor is provided (see feature
readline
)
and 15 otherwise.
- gc (bool)
-
If true (default), the garbage collector is active. If false, neither
garbage-collection, nor stack-shifts will take place, even not on
explicit request. May be changed.
- iso (bool)
-
Include some weird ISO compatibility that is incompatible to normal
SWI-Prolog behaviour. Currently it has the following effect:
- is/2 and
evaluation under flag/3
do not automatically convert floats to integers if the float represents
an integer.
- In the standard order of terms (see section
3.5.1), all floats are before all integers.
- trace_gc (bool)
-
If true (false is the default), garbage collections and stack-shifts
will be reported on the terminal. May be changed.
- max_arity (unbounded)
-
ISO feature describing there is no maximum arity to compound terms.
- integer_rounding_function (down,toward_zero)
-
ISO feature describing rounding by
//
and rem
arithmetic functions. Value depends on the C-compiler used.
- bounded (true)
-
ISO feature describing integer representation is bound by
min_integer and min_integer.
- tty_control (bool)
-
Determines whether the terminal is switched to raw mode for
get_single_char/1,
which also reads the user-actions for the trace. May be set. See also
the +/-tty command-line option.
- debug_on_error (bool)
-
If true, start the tracer after an error is detected.
Otherwise just continue execution. The goal that raised the error will
normally fail. See also fileerrors/2
and the feature report_error. May be changed. Default is true,
except for the runtime version.
- report_error (bool)
-
If true, print error messages, otherwise suppress them.
May be changed. See also the debug_on_error feature.
Default is true, except for the runtime version.
- unix (bool)
-
If true, the operating system
is some version of Unix. Defined if the C-compiler used to compile this
version of SWI-Prolog either defines
__unix__
or unix
.
- windows (bool)
-
If true, the operating
system is an implementation of Microsoft Windows (3.1, 95, NT, etc.).
- set_feature(+Key,
+Value)
-
Define a new feature or change its value. Key is an atom,
Value is an atom or number.