Next: ref-iou-tou-dis, Previous: ref-iou-tou-wrt, Up: ref-iou-tou [Contents][Index]
The output of the “write” predicates is not terminated by a full stop;
therefore, if you want the term to be acceptable as input to read/[1,2]
, then
you must send the terminating full stop to the output stream yourself. For example,
| ?- write(a), write(' .'), nl.
Note that, in general, you need to prefix the full stop with a layout character, like space, to ensure that it can not “glue” with characters in the term.
If Term is uninstantiated, then it is written as an anonymous variable (an underscore followed by a non-negative integer).
Please note: The “name” used when writing a variable may differ between separate calls to a ‘Write“ predicate. If this is a concern, then you can use either of the following methods to ensure that the variable is always written in same way.
variable_names/1
write_term
option to
explicitly name the variable. This option was added in release 4.3.
numbervars/3
to bind the variables in the written term to (ground)
'$VAR'(N)
terms and use the numbervars(true)
write_term
option. Note that this may not work with
attributed variables, like those used by library(clpfd)
.
write_canonical/[1,2]
is provided so that Term, if written to a
file, can be read back by read/[1,2]
regardless whether there are special
characters in Term or prevailing operator declarations.