11.3.245 write_canonical/[1,2] [ISO]

Synopsis

write_canonical(+Stream, +Term)

write_canonical(+Term)

Writes Term on the standard output stream, quoting atoms, without operator notation, without treating '$VAR'/1 terms specially.

Arguments

Stream
stream_object, must be ground

A valid open Prolog stream, defaults to the current output stream.

Term
term

Description

This predicate is provided so that Term, if written to a file, can be read back by read/[1,2] regardless of special characters in Term or prevailing operator declarations.

write_canonical(Term) is equivalent to:

     write_term(Term, [quoted(true),ignore_ops(true),quoted_charset(portable)])

Exceptions

Stream errors (see ref-iou-sfh-est).

Examples

To contrast write/[1,2] and write_canonical/[1,2]:

     | ?- write({'A' + '$VAR'(0) + [a]}).
     
     {A+A+[a]}
     
     | ?- write_canonical({'A' + '$VAR'(0) + [a]}).
     
     {}(+(+('A','$VAR'(0)),.(a,[])))

See Also

ref-iou-tou.


Send feedback on this subject.