[ Term I/O | Reference Manual | Alphabetic Index ]
The term Term is written on the output stream Stream in a form that can be
- Stream handle or alias (atom)
- Prolog term.
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 (stream-specific or global) 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
writeq(Term) is equivalent to printf("%DIMQvw", Term)
or write_term(Term, [attributes(full),quoted(true),numbervars(true),
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.
Note also that although it is possible to print suspensions and external
handles, these are printed in their printed representation as Prolog
terms with functors such as '$&'/2 (for handles). They will be read
back in as such Prolog terms, rather than as their original type.
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 a stream handle.
- (192) illegal stream mode
- Stream is not an output stream.
- (193) illegal stream specification
- Stream is an illegal stream specification.
?- writeq(output, "string"),nl(output),
head :- body
1 ^ 2 * (3 + 4)
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).
write / 1, write / 2, writeq / 1