[ Term I/O | The ECLiPSe Built-In Predicates | Reference Manual | Alphabetic Index ]

write_canonical(+Stream, ?Term)

The term Term is written on the output stream Stream in a form that ignores operator declarations and can be read in.
Integer (stream number) or Atom (reserved or user-defined symbolic stream name).
Prolog term.


Used to write the term Term in a form that can be read back independent of the current operator declarations. Atoms and strings are quoted, operator declarations are ignored, lists are printed as ./2 structures, the (stream-specific or global) print_depth flag is not taken into account, variable attributes are printed, and variables are printed with unique identifiers.

write_canonical(S, Term) is equivalent to printf(S, "%MOQ.vDw", Term).

Note that as usual, the output is buffered, so it may need to be flushed either by closing the stream, by writing again or by using flush/1.

Modes and Determinism


This predicate is sensitive to its module context (tool predicate, see @/2).


(4) instantiation fault
Stream is not instantiated.
(5) type error
Stream is not an atom or an integer.
(192) illegal stream mode
Stream is not an output stream.
(193) illegal stream specification
Stream is an illegal stream specification.


    [eclipse 1]: write_canonical(output, 'A'+[a,B]).
    +('A', .(a, .(_216, [])))
    B = B

    write_canonical(S, a(b,c)).        (Error 4).
    write_canonical("string", a(b,c)). (Error 5).
    write_canonical(input, X + 2).     (Error 192).
    write_canonical(atom, X + 2).      (Error 193).

See Also

write / 1, write / 2, writeq / 1, writeq / 2, write_canonical / 1