The predicates current_prolog_flag/2 and set_prolog_flag/2 allow the user to examine and modify the execution environment. It provides access to whether optional features are available on this version, operating system, foreign-code environment, command-line arguments, version, as well as runtime flags to control the runtime behaviour of certain predicates to achieve compatibility with other Prolog environments.
bool
can have the values true
and
false
. Some Prolog flags are not defined in all versions,
which is normally indicated in the documentation below as ``if
present and true''. A Boolean Prolog flag is true iff the Prolog
flag is present and the Value is the atom true
.
Tests for such flags should be written as below.
( current_prolog_flag(windows, true) -> <Do MS-Windows things> ; <Do normal things> )
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 to non-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.pl
(default) or pro
(can be selected in the installer))
associated with plwin.exe.true
(default) autoloading of library functions is
enabled. Note that autoloading only works if the flag unknown
is
not set to fail
. See section
2.13.true
(default false
), read translates text
between backquotes into a string object (see section
4.23). This flag is mainly for compatibility to LPA Prolog.true
, integer representation is bound
by
min_integer and max_integer.
If false
integers can be arbitrarily large and the min_integer
and
max_integer are
not present. See section 4.26.2.1.true
(default), read/1
interprets \
escape sequences in quoted atoms and strings.
May be changed. This flag is local to the module in which it is changed.true
in plwin.exe to indicate the console
supports menus. See also section
4.34.2.library(thread)
. Currently this flag is supported in
Windows and Linux if
/proc
is enabled. If you can provide us with a C-code
fragment getting the number for a specific OS, please submit an
enhancement report at http://gollem.science.uva.nl/bugzilla/true
if this instance of Prolog supports DDE as
described in section 4.42.Disabling these optimisations can cause the system to run out of memory on programs that behave correctly if debug mode is off.
[quoted(true),
portray(true), max_depth(10), attributes(portray)]
.true
, show the context module while printing a
stack-frame in the tracer. Normally controlled using the `C' option of
the tracer.swi
. The code below is a reliable and portable way
to detect SWI-Prolog.
is_dialect(swi) :- catch(current_prolog_flag(dialect, swi), _, fail).
codes
(default), a list of character-codes is returned, if
chars
a list of one-character atoms, if atom
double quotes are the same as single-quotes and finally, string
reads the text into a Prolog string (see section
4.23). See also
atom_chars/2
and atom_codes/2.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 consequences 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. On most systems using sparse-memory management 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).
EMACS
is t
and INFERIOR
is yes
.text
mode. The
initial value is deduced from the environment. See section
2.17.1 for details.true
(default false
), expand $varname
and ~
in arguments of built-in predicates that
accept a file name (open/3, exists_file/1, access_file/2,
etc.). The predicate
expand_file_name/2
can be used to expand environment variables and wildcard patterns. This
Prolog flag is intended for backward compatibility with older versions
of SWI-Prolog.When using quoted-write, the output is guaranteed to contain a decimal dot or exponent, so read/1 reads a floating point number. See also format/[1,2], write_term/[2,3].
true
(default) generate code that can be debugged using
trace/0, spy/1,
etc. Can be set to false
using the
-nodebug. The predicate load_files/2
restores the value of this flag after loading a file, causing
modifications to be local to a source file. Many of the libraries have
:- set_prolog_flag(generate_debug_info, false)
to hide
their details from a normal trace.7In
the current implementation this only causes a flag to be set on the
predicate that causes children to be hidden from the debugger. The name
anticipates on anticipated changes to the compiler.true
if XPCE is around and can be used for graphics.<home>/boot32.prc
(32-bit machines) or
<home>/boot64.prc
(64-bit machines) and to
find its library as
<home>/library
.//
and rem
arithmetic functions. Value depends on the C-compiler used.true
, SWI-Prolog has been compiled with
large file support (LFS) and is capable to access files larger
than 2GB on 32-bit hardware. Large file-support is default on
installations built using configure that support it and may be
switched off using the configure option --disable-largefile
.false
(default), unification succeeds, creating an infinite
tree. Using true
, unification behaves as unify_with_occurs_check/2,
failing silently. Using error
, an attempt to create a
cyclic term results in an occurs_check
exception. The
latter is intended for debugging unintentional creations of cyclic
terms. Note that this flag is a global flag modifying fundamental
behaviour of Prolog. Changing the flag from its default may cause
libraries to stop functioning properly..so
files) or dynamic link libraries (.DLL
files).true
, compile in optimised mode. The initial value is
true
if Prolog was started with the -O
command-line option.
Currently optimise compilation implies compilation of arithmetic, and deletion of redundant true/0 that may result from expand_goal/2.
Later versions might imply various other 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).
open(pipe(command), mode, Stream)
, etc. are
supported. Can be changed to disable the use of pipes in applications
testing this feature. Not recommended.determinism
, which implies the system prompts for
alternatives if the goal succeeded while leaving choicepoints. Many
classical Prolog systems behave as groundness
: they prompt
for alternatives if and only if the query contains variables.boot32.prc
, the file specified with -x
or the running executable. See also resource/3.true
, print error messages, otherwise suppress them. May
be changed. See also the debug_on_error
Prolog flag. Default is true
, except for the runtime
version.true
, SWI-Prolog is compiled with
-DO_RUNTIME, disabling various useful development features (currently
the tracer and profiler).true
, Prolog has been started from a state
saved with qsave_program/[1,2]..so
for most Unix systems and .dll
for Windows. Used for
locating files using the file_type
executable
.
See also
absolute_file_name/3.false
if the hosting OS does not support signal
handling or the command-line option -nosignals is
active. See
section 9.6.20.1 for
details.timezone
variable associated
with the POSIX tzset() function. See also convert_time/2.true
, top-level variables starting with an underscore (_
)
are printed normally. If false
they are hidden. This may be
used to hide bindings in complex queries from the top-level.[quoted(true),
portray(true), max_depth(10), attributes(portray)]
.$
variable reference. See section
2.8.% GC: gained 236,416+163,424 in 0.00 sec; used 13,448+5,808; free 72,568+47,440
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
. On other systems this flag is not available.fail
, the predicates fails silently. If warn
,
a warning is printed, and execution continues as if the predicate was
not defined and if error
(default), an existence_error
exception is raised. This flag is local to each module. Switching this
flag to
fail
disables autoloading and thus forces complete and
consistent use of use_module/[1,2]
to load the required libraries.silent
, messages of type informational
and banner
are suppressed. The -q switches
the value from the initial
normal
to silent
.true
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.false
normal consult messages will be suppressed.
Default is
true
. The value of this flag is normally controlled by the
option silent(Bool)
provided by load_files/2.true
(default false
), print messages
indicating the progress of absolute_file_name/[2,3]
in locating files. Intended for debugging complicated file-search paths.
See also file_search_path/2.10000 × Major + 100 × Minor + PatchNote that in releases up to 2.7.10 this Prolog flag yielded an atom holding the three numbers separated by dots. The current representation is much easier for implementing version-conditional statements.
[]
.true
, the
operating system is an implementation of Microsoft Windows (NT/2000/XP,
etc.). This flag is only available on MS-Windows based versions.attributes
option of
write_term/3.
Default is ignore
.true
it prints
bold and underlined text using
overstrike.true
if the XPCE graphics system is
loaded.permission_error
. If the provided Value does not
match the type of the flag, a type_error
is raised.
In addition to ISO, SWI-Prolog allows for user-defined Prolog flags.
The type of the flag is determined from the initial value and cannot be
changed afterwards. Defined types are boolean
(if the
initial value is one of false
, true
, on
or off
),
atom
if the initial value is any other atom, integer
if the value is an integer that can be expressed as a 64-bit signed
value. Any other initial value results in an untyped flag that can
represent any valid Prolog term.