Author(s): Adapted from shared code written by Richard A. O'Keefe. Changes by Mats Carlsson, Daniel Cabeza, and Manuel Hermenegildo..
Version: 1.5#118 (2000/4/19, 18:13:43 CEST)
Version of last change: 0.5#49 (1998/7/14, 20:3:29 MET DST)
This library provides different predicates for term output, additional to the kernel predicates
display/1
-
display/2
and displayq/1
-displayq/2
. All the predicates defined in ISO-Prolog are included, plus other traditionally provided by Prolog Implementations. Output predicates are provided in two versions: one that uses the current output stream and other in which the stream is specified explicitly, as an additional first argument.
write
):- use_module(library(write)).
write_term/3
,
write_term/2
,
write/2
,
write/1
,
write_list1/1
,
writeq/2
,
writeq/1
,
write_canonical/2
,
write_canonical/1
,
print/2
,
print/1
,
portray_clause/2
,
portray_clause/1
,
numbervars/3
,
prettyvars/1
,
printable_char/1
.
write_option/1
.
define_flag/3
,
portray_attribute/2
,
portray/1
.
write
)
Usage: write_term(@(Stream),?(Term),+OptList)
* ISO *
Term
to the stream Stream
, with the list of write-options OptList
. See
write_option/1
type for default options.
@(Stream)
is an open stream.
(streams_basic:stream/1
)
?(Term)
is any term.
(basic_props:term/1
)
+OptList
is a list of write_option
s.
(basic_props:list/2
)
Usage: write_term(?(Term),+OptList)
* ISO *
current_output(S), write_term(S,Term,OptList)
.
?(Term)
is any term.
(basic_props:term/1
)
+OptList
is a list of write_option
s.
(basic_props:list/2
)
Opt
is a valid write option which affects the predicate write_term/3
and similar ones. Possible write_options are:
true
, atoms and functors that can't be read back by
read_term/3
are quoted, if it is false
, each atom and functor is written as its name. Default value is false
.
true
, each compound term is output in functional notation, if it is ops
, curly bracketed notation and list notation is enabled when outputing compound terms, if it is false
, also operator notation is enabled when outputing compound terms. Default value is false
.
true
, a term of the form '$VAR'(N)
where N
is an integer, is output as a variable name consisting of a capital letter possibly followed by an integer, a term of the form '$VAR'(Atom)
where Atom
is an atom, as this atom (without quotes), and a term of the form '$VAR'(String)
where String
is a character string, as the atom corresponding to this character string. See predicates numbervars/3
and prettyvars/1
. If bool is false
this cases are not treated in any special way. Default value is false
.
true
, then call multifile predicates
portray/1
and
portray_attribute/1
, to provide the user handlers for pretty printing some terms. portray_attribute/1
is called whenever an attributed variable is to be printed, portray/1
is called whenever a non-variable term is to be printed. If either call succeeds, then it is assumed that the term has been output, else it is printed as usual. If bool is false
, these predicates are not called. Default value is false
. This option is set by the toplevel when writting the final values of variables, and by the debugging package when writting the goals in the tracing messages. Thus you can vary the forms of these messages if you wish.
0
(no limit).
.
Usage: write_option(Opt)
Opt
is a valid write option.
Usage: write(@(Stream),?(Term))
* ISO *
write_term(Stream, Term, [numbervars(true)])
.
@(Stream)
is an open stream.
(streams_basic:stream/1
)
?(Term)
is any term.
(basic_props:term/1
)
Usage: write(?(Term))
* ISO *
current_output(S), write(S,Term)
.
?(Term)
is any term.
(basic_props:term/1
)
Usage:
Arg1
is a list.
(basic_props:list/1
)
Arg1
is a list.
(basic_props:list/1
)
Usage: writeq(@(Stream),?(Term))
* ISO *
write_term(Stream, Term, [quoted(true), numbervars(true)])
.
@(Stream)
is an open stream.
(streams_basic:stream/1
)
?(Term)
is any term.
(basic_props:term/1
)
Usage: writeq(?(Term))
* ISO *
current_output(S), writeq(S,Term)
.
?(Term)
is any term.
(basic_props:term/1
)
Usage: write_canonical(@(Stream),?(Term))
* ISO *
write_term(Stream, Term, [quoted(true), ignore_ops(true)])
. The output of this predicate can always be parsed by
read_term/2
even if the term contains special characters or if operator declarations have changed.
@(Stream)
is an open stream.
(streams_basic:stream/1
)
?(Term)
is any term.
(basic_props:term/1
)
Usage: write_canonical(?(Term))
* ISO *
current_output(S), write_canonical(S,Term)
.
?(Term)
is any term.
(basic_props:term/1
)
Usage: print(@(Stream),?(Term))
write_term(Stream, Term, [numbervars(true), portrayed(true)])
.
@(Stream)
is an open stream.
(streams_basic:stream/1
)
?(Term)
is any term.
(basic_props:term/1
)
Usage: print(?(Term))
current_output(S), print(S,Term)
.
?(Term)
is any term.
(basic_props:term/1
)
Usage: portray_clause(@(Stream),?(Clause))
Clause
onto Stream
, pretty printing its variables and using indentation, including a period at the end. This predicate is used by listing/0
.
@(Stream)
is an open stream.
(streams_basic:stream/1
)
?(Clause)
is any term.
(basic_props:term/1
)
Usage: portray_clause(?(Clause))
current_output(S), portray_clause(S,Term)
.
?(Clause)
is any term.
(basic_props:term/1
)
Usage: numbervars(?(Term),+N,?(M))
Term
with a term of the form '$VAR'(I)
where I
is an integer from N
onwards. M
-1 is unified with the last integer used. If the resulting term is output with a write option numbervars(true)
, in the place of the variables in the original term will be printed a variable name consisting of a capital letter possibly followed by an integer. When N
is 0 you will get the variable names A, B, ..., Z, A1, B1, etc.
?(Term)
is any term.
(basic_props:term/1
)
+N
is currently instantiated to an integer.
(term_typing:integer/1
)
?(M)
is currently instantiated to an integer.
(term_typing:integer/1
)
Usage: prettyvars(?(Term))
numbervars(Term,0,_)
, except that singleton variables in Term
are unified with '$VAR'('_')
, so that when the resulting term is output with a write option numbervars(true)
, in the place of singleton variables _
is written. This predicate is used by
portray_clause/2
.
?(Term)
is any term.
(basic_props:term/1
)
No further documentation available for this predicate.
write
)Defines flags as follows:
define_flag(write_strings,[on,off],off).
(See section Changing system behaviour and various flags)
The predicate is multifile.
No further documentation available for this predicate.
The predicate is multifile.
The predicate is multifile.
Usage: portray(?(Term))
Term
and succeed, or do nothing and fail. In the latter case, the default printer (write/1
) will print the Term
.
Go to the first, previous, next, last section, table of contents.