ignore
(ignore the attribute), dots
(write the attributes as {...}
), write
(simply
hand the attributes recursively to write_term/2)
and portray
(hand the attributes to attr_portray_hook/2).string
causes string
objects to be printed between back quotes and symbol_char
causes the backquote to be printed unquoted. In all other cases the
backquote is printed as a quoted atom.true
(default), write {}(X)
as {X}
.
See also
dotlists
and ignore_ops
.portray
,
portray/1
is called for each blob encountered. See section
12.4.8.true
and quoted(true)
is active, special
characters in quoted atoms and strings are emitted as ISO escape
sequences. Default is taken from the reference module (see below).true
(default), cyclic terms are written as
@(Template, Substitutions)
, where Substitutions
is a list
Var = Value. If cycles
is false
,
max_depth
is not given, and Term is cyclic, write_term/2
raises a domain_error
.94The
cycles option and the cyclic term representation using the @-term are
copied from SICStus Prolog. However, the default in SICStus is set to false
and SICStus writes an infinite term if not protected by, e.g., the depth_limit
option. See also the cycles
option in
read_term/2.true
(default false
), write lists using the
dotted term notation rather than the list notation.95Copied
from ECLiPSe. Note that as of versionĀ 7, the list
constructor is
'[|]'
. Using dotlists(true)
, write_term/2
writes a list using `.' as constructor. This is intended for
communication with programs such as other Prolog systems, that rely on
this notation.true
(default false
), add a fullstop token
to the output. The dot is preceeded by a space if needed and followed by
a space (default) or newline if the nl(true)
option is also
given.96Compatible with ECLiPSetrue
, the generic term representation (<functor>(<args>
... )) will be used for all terms. Otherwise (default), operators will
be used where appropriate.97In
traditional systems this flag also stops the syntactic sugar notation
for lists and brace terms. In SWI-Prolog, these are controlled by the
separate options dotlists
and brace_terms
.?- write_term(a(s(s(s(s(0)))), [a,b,c,d,e,f]), [max_depth(3)]). a(s(s(...)), [a, b|...]) true.
Used by the top level and debugger to limit screen output. See also the Prolog flags answer_write_options and debugger_write_options.
user
). This defines
the default value for the character_escapes
option as well as the operator definitions to use. See also op/3.fullstop
option.true
, terms of the format $VAR(N)
, where N
is a non-negative integer, will be written as a variable name. If N
is an atom it is written without quotes. This extension allows for
writing variables with user-provided names. The default is false
.
See also numbervars/3
and the option variable_names
.true
(default false
), do not reset the
logic that inserts extra spaces that separate tokens where needed. This
is intended to solve the problems with the code below. Calling write_value(.
)
writes ..
, which cannot be read. By adding partial(true)
to the option list, it correctly emits . .
. Similar
problems appear when emitting operators using multiple calls to write_term/3.
write_value(Value) :- write_term(Value, [partial(true)]), write('.'), nl.
portrayed(Bool)
. Deprecated.portray(true)
, but calls Goal rather
than the predefined hook portray/1. Goal
is called through call/3,
where the first argument is Goal, the second is the term to
be printed and the 3rd argument is the current write option list. The
write option list is copied from the write_term call, but the list is
guaranteed to hold an option priority
that reflects the
current priority.true
, the hook portray/1
is called before printing a term that is not a variable. If portray/1
succeeds, the term is considered printed. See also print/1.
The default is false
. This option is an extension to the
ISO write_term options.format('~w = ', [VarName]), write_term(Value, [quoted(true), priority(699)])
true
, atoms and functors that need quotes will be
quoted. The default is false
.standard
, adding only space
where needed for proper tokenization by read_term/3.
Currently, the only other value is next_argument
, adding a
space after a comma used to separate arguments in a term or list.
The implementation binds the variables from List to a term
'$VAR'
(Name). Like write_canonical/1,
terms that where already bound to '$VAR'
(X)
before write_term/2
are printed normally, unless the option numbervars(true)
is
also provided. If the option numbervars(true)
is used, the
user is responsible for avoiding collisions between assigned names and
numbered names. See also the variable_names
option of
read_term/2.
Possible variable attributes (see section 8.1) are ignored. In most cases one should use copy_term/3 to obtain a copy that is free of attributed variables and handle the associated constraints as appropriate for the use-case.