Previous Up Next

8.22  Prolog state

8.22.1  set_prolog_flag/2

Templates

set_prolog_flag(+flag, +term)

Description

set_prolog_flag(Flag, Value) sets the value of the Prolog flag Flag to Value.

Prolog flags: a Prolog flag is an atom which is associated with a value that is either implementation defined or defined by the user. Each flag has a permitted range of values; any other value is a domain_error. The following two tables present available flags, the possible values, a description and if they are ISO or an extension. The first table presents unchangeable flags while the second one the changeable flags. For flags whose default values is machine independent, this value is underlined.

Unchangeable flags:

Flag
Values
Description
ISO
prolog_name
an atom
name of the Prolog system
N
prolog_version
an atom
version number of the Prolog system
N
prolog_date
an atom
date of the Prolog system
N
prolog_copyright
an atom
copyright message of the Prolog system
N
dialect
an atom
fixed to gprolog
N
version
an integer
Major * 10000 + Minor * 100 + Patch
N
version_data
a structure
gprolog(Major,Minor,Patch,Extra)
N
bounded
true / false
are integers bounded ?
Y
max_integer
an integer
greatest integer
Y
min_integer
an integer
smallest integer
Y
integer_rounding_function
toward_zero
down
rnd(X) = integer part of X
rnd(X) = ⌊X⌋ (section 8.6.1)
Y
max_arity
an integer
maximum arity for compound terms (255)
Y
max_atom
an integer
maximum number of atoms
N
max_unget
an integer
maximum number of successive ungets
N
home
an atom
GNU Prolog home directory
N
host_os
an atom
Operating System identifier
N
host_vendor
an atom
Operating System vendor
N
host_cpu
an atom
processor identifier
N
host
an atom
a combination of the OS-vendor-cpu
N
arch
an atom
a combination of the OS-cpu
N
address_bits
an integer
address size of the machine (32 or 64)
N
unix
on/off
is the architecture an Unix-like OS ?
N
compiled_at
an atom
compilation date using __DATE__ and __TIME__ C compiler macros
N
c_cc
an atom
C compiler used to compile GNU Prolog (gcc, cc, clang, cl,...)
N
c_cc_version_data
a structure
c_cc(Major,Minor,Patch,Extra)
N
c_cflags
an atom
CFLAGS used to compile GNU Prolog
N
c_ldflags
an atom
LDFLAGS used to compile GNU Prolog
N
argv
a list of atoms
list of command-line arguments
N

Changeable flags:

Flag
Values
Description
ISO
char_conversion
on / off
is character conversion activated ?
Y
singleton_warning
on / off
warn about named singleton variables ?
N
suspicious_warning
on / off
warn about suspicious predicate ?
N
multifile_warning
on / off
warn about unsupported multifile directive ?
N
strict_iso
on / off
strict ISO behavior ?
N
debug
on / off
is the debugger activated ?
Y
 
double_quotes
 
atom
chars
codes
atom_no_escape
chars_no_escape
codes_no_escape
a double quoted constant is returned as:
an atom
a list of characters
a list of character codes
as atom but ignore escape sequences
as chars but ignore escape sequences
as code but ignore escape sequences
 
Y
 
 
N
 
back_quotes
 
atom
chars
codes
atom_no_escape
chars_no_escape
codes_no_escape
a back quoted constant is returned as:
an atom
a list of characters
a list of character codes
as atom but ignore escape sequences
as chars but ignore escape sequences
as code but ignore escape sequences
 
N
 
unknown
 
error
warning
fail
a predicate calls an unknown procedure:
an existence_error is raised
a message is displayed then fails
quietly fails
 
Y
 
syntax_error
 
error
warning
fail
a predicate causes a syntax error:
a syntax_error is raised
a message is displayed then fails
quietly fails
 
N
 
os_error
 
error
warning
fail
a predicate causes an O.S. error:
a system_error is raised
a message is displayed then fails
quietly fails
 
N

The strict_iso flag is introduced to allow a compatibility with other Prolog systems. When turned off the following relaxations apply:

Errors

Flag is a variable  instantiation_error
Value is a variable  instantiation_error
Flag is neither a variable nor an atom  type_error(atom, Flag)
Flag is an atom but not a valid flag  domain_error(prolog_flag, Flag)
Value is inappropriate for Flag  domain_error(flag_value, Flag+Value)
Value is appropriate for Flag but flag Flag is not modifiable  permission_error(modify, flag, Flag)

Portability

ISO predicate. All ISO flags are implemented.

8.22.2  current_prolog_flag/2

Templates

current_prolog_flag(?flag, ?term)

Description

current_prolog_flag(Flag, Value) succeeds if there exists a Prolog flag that unifies with Flag and whose value unifies with Value. This predicate is re-executable on backtracking.

Errors

Flag is neither a variable nor an atom  type_error(atom, Flag)
Flag is an atom but not a valid flag  domain_error(prolog_flag, Flag)

Portability

ISO predicate.

8.22.3  set_bip_name/2

Templates

set_bip_name(+atom, +arity)

Description

set_bip_name(Functor, Arity) initializes the context of the error (section 6.3.1) with Functor and Arity (if Arity < 0 only Functor is significant).

Errors

Functor is a variable  instantiation_error
Arity is a variable  instantiation_error
Functor is neither a variable nor an atom  type_error(atom, Functor)
Arity is neither a variable nor an integer  type_error(integer, Arity)

Portability

GNU Prolog predicate.

8.22.4  current_bip_name/2

Templates

current_bip_name(?atom, ?arity)

Description

current_bip_name(Functor, Arity) succeeds if Functor and Arity correspond to the context of the error (section 6.3.1) (if Arity < 0 only Functor is significant).

Errors

Functor is neither a variable nor an atom  type_error(atom, Functor)
Arity is neither a variable nor an integer  type_error(integer, Arity)

Portability

GNU Prolog predicate.

8.22.5  write_pl_state_file/1, read_pl_state_file/1

Templates

write_pl_state_file(+source_sink)
read_pl_state_file(+source_sink)

Description

write_pl_state_file(FileName) writes onto FileName all information that influences the parsing of a term (section 8.14). This allows a sub-process written in Prolog to read this file and then process any Prolog term as done by the parent process. This file can also be passed as argument of the --pl-state option when invoking gplc (section 4.4.3). More precisely the following elements are saved:

read_pl_state_file(FileName) reads (restores) from FileName all information previously saved by write_pl_state_file/1.

Errors

FileName is a variable  instantiation_error
FileName is neither a variable nor an atom  type_error(atom, FileName)
an operating system error occurs and the value of the os_error Prolog flag is error (section 8.22.1)  system_error(atom explaining the error)

Portability

GNU Prolog predicate.


Copyright (C) 1999-2021 Daniel Diaz Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. More about the copyright
Previous Up Next