[ ECLiPSe Term-based I/O built-in.|Group Index| Full Index]

writeq(+Stream, ?Term)

The term Term is written on the output stream Stream in a form that can be read in.

+Stream
Integer (stream number) or Atom (reserved or user-defined symbolic stream name).
?Term
Prolog term.

Description

Used to write the term Term on the output stream Stream according to the current operator declarations. Atoms and strings are quoted, operator expressions parenthesised (whenever necessary) and the print_depth flag is not taken into account. The output of writeq/2 can be read back, provided that the same operator declarations are in effect at write and read time. writeq(S, Term) is equivalent to printf(S, "%QDvw", 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.

Fail Conditions

None.

Resatisfiable

No.

Exceptions

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

Examples


   Success:
      [eclipse]: writeq(output, "string"),nl(output),
      > writeq(output, head:-body).
      "string"
      head :- body
      yes.

      [eclipse]: writeq(*(^(1,2),+(3,4))).
      1 ^ 2 * (3 + 4)
      yes.
Error:
      writeq(S, a(b,c)).        (Error 4).
      writeq("string", a(b,c)). (Error 5).
      writeq(9, X + 2).         (Error 192).
      writeq(atom, X + 2).      (Error 193).

See Also

write / 1, write / 2, writeq / 1