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
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, 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, you can use either of the following methods to ensure that the variable is always written in same way.
write_termoption to explicitly name the variable. This option was added in release 4.3.
numbervars/3to bind the variables in the written term to (ground)
)terms and use the
write_termoption. Note that this may not work with attributed variables, like those used by
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.