Release 3 had the notion of multiple language modes: iso
and
sicstus
. Release 4 does not have this notion. The syntax and
semantics of the Prolog language correspond to the previous
iso
language mode.
The exact rules for translating DCG rules to plain Prolog clauses have not been laid down in a standard, but there is a broad consensus in the Prolog community about what they should mean. One of the guiding principles is that the translation should be steadfast, in particular that the translated code should always treat its last argument as an output argument and not use it “too early”. In some cases, a non-steadfast translation was produced in release 3. This has been corrected in release 4.
In release 3, terms containing attributed variables and blocked goals
could be asserted, copied, gathered as solutions to findall/3
and friends, and raised as exceptions. The copy would contain new
attributed variables with the attributes copied. This operation could
be very expensive, could yield unexpected results and was not always
safe e.g. in the context of CLPFD constraints. In release 4, the
semantics of this operation has changed: in the copy, an attributed
variable is simply replaced by a plain, brand new variable. Of
course, if the same attributed variable occurs more than once, the
same plain variable will occur in the corresponding places in the
copy. If the attributes are relevant, the program can obtain them by
using the new built-in predicate copy_term/3
described below.
The infix operator `#' (bitwise exclusive or) has been renamed to `\'.
Atoms can now contain the <NUL> character, i.e. character code
zero. It is classified as white space and must therefore be entered
using escapes. As an example 'a\0\a'
is a three character atom
containing two a
s separated by a <NUL>.
Internally, atom names and other encoded strings, use the non-shortest form `0xC0 0x80' to encode <NUL>. This is similar to how <NUL> is handled by Tcl/Tk and Java.
The language
and wcx
Prolog flag have been dropped.
The profiledcode
value of the compiling
Prolog flag has been dropped.
Several new Prolog flags have been added.
See Prolog Flags.
The wcx
property has been dropped.
Several new stream properties have been added.
See stream_property/2
.
Several new statistics keywords have been added.
See statistics/[0,1]
.
The set of built-in predicates has changed slightly. The following predicates have been removed:
'C'/3
get0/[1,2]
put/[1,2]
get/[1,2]
tab/[1,2]
skip/[1,2]
get0/[1,2]
and put/[1,2]
.
We have provided skip_char/[1,2]
, skip_code/[1,2]
, and
skip_byte/[1,2]
as an ISO style replacement for
skip/[1,2]
.
ttyget0/1
ttyget/1
ttynl/0
ttyput/1
ttyskip/1
ttytab/1
ttyflush/0
user
argument. In most cases, the “respective
predicate” is one of the non-ISO style predicate mentioned above, so
there was no point in keeping the shorthand.
fileerrors/0
nofileerrors/0
set_prolog_flag/2
with
specific arguments, and so can be trivially replaced.
call_residue/2
call_residue_vars/2
, which should
suffice in most cases where call_residue/2
was used; see below.
undo/1
prolog:undo/1
. The argument should
have a module prefix.
help/0
version/0
version/1
fcompile/1
load/1
load_foreign_files/2
require/1
:- use_module/2
directives, and so the shorthand was dropped.
profile_data/4
profile_reset/1
The following predicates have been added:
call/
Ncall/1
. For example, call(p(1,2), a, b)
is
equivalent to call(p(1,2, a, b))
.
skip_char/[1,2]
skip_code/[1,2]
skip_byte/[1,2]
skip/[1,2]
.
call_residue_vars/2
call_residue_vars(:Goal, -Vars)
Executes the procedure call Goal, unifying Vars with
the list of residual variables that have blocked goals or attributes
attached to them. Please note: behaves differently from
call_residue/2
of release 3.
copy_term/3
copy_term(+Term, -Copy, -Body)
Unifies Copy with a copy of Term in which all variables have
been replaced by brand new variables, and all mutables by brand new
mutables. If Term contains variables with goals blocked on them,
or variables with attributes that can be interpreted as a goal
(see library(atts)
), then Body is unified with the conjunction of
such goals. If no such goals are present, Body is unified with
the atom true
. The idea is that executing Body
will reinstate blocked goals and attributes on the variables in Copy
equivalent to those on the variables in Term.
profile_reset/0
profile_data/1
print_profile/[0,1]
coverage_data/1
print_coverage/[0,1]
Some predicates have been changed slightly; in most cases, this affects predicates that take a list of options:
[
F1,
F2,...]
load_files([
F1,
F2,...])
.
is_mutable/1
is_mutable/1
has been renamed to
mutable/1
, in analogy with integer/1
, atom/1
etc.
module/1
module/1
has been renamed to
set_module/1
, to avoid possible confusion with the
module/2
declaration.
format/[2,3]
format/[2,3]
, the semantics of the `~@'
spec has changed slightly: the goal Arg is called as if by
\+ \+
Arg, i.e. any bindings made by the goal are lost.
close/2
direction/1
open/4
wcx/1
option has been dropped.
Takes several new options.
See open/4
.
absolute_file_name/[2,3]
ignore_underscores/1
option has been dropped.
The file_type/1
option value ql
has been dropped,
whereas the option value executable
is new.
The access/1
option values execute
,
executable
and search
are new.
The glob/1
option is new, allowing to match file names against a
pattern.
If available, the load
context directory (prolog_load_context/2
) will be used as default directory.
load_files/2
load_type/1
option value ql
has been dropped.
encoding_signature/1
, encoding/1
, subsuming the wcx/1
option of
release 3, and eol/1
, are new options, corresponding to the
respective stream properties.
write_term/3
quoted_charset/1
option is new, reflecting the value of the
Prolog flag with the same name.
halt/1
halt/1
now raises an internal exception like
halt/0
. This gives surrounding Prolog and C code an opportunity
to perform cleanup.
append/3
member/2
memberchk/2
library(lists)
.
The hook user:term_expansion/[2,4]
is replaced by the hook:
user:term_expansion(Term1, Layout1, Tokens, Term2, Layout2, [Token|Tokens]).
The purpose of the new argument Tokens is to support multiple, independent expansion rules. The purpose of the arguments Layout1 and Layout2 is to support source-linked debugging of term-expanded code. Each expansion rule should have its unique identifying token Token.
The hook user:goal_expansion/3
is replaced by the following per-module hook:
M:goal_expansion(Term1, Layout1, Module, Term2, Layout2).
Typically, Module has imported the predicate Term1 from module M. The purpose of the arguments Layout1 and Layout2 is to support source-linked debugging of goal-expanded code.