[ Term I/O | Reference Manual | Alphabetic Index ]
The term Term is written on the output stream Stream according to the
current operator declarations.
- Stream handle or alias (atom)
- Prolog term.
Used to write the term Term on the output stream Stream according to the
current operator declarations. Lists and compound terms are only
printed up to the nesting depth specified by the (stream-specific or
global) print_depth setting (cf. set_stream_property/3, set_flag/2).
write(Term) is equivalent to write_term(Term, [numbervars(true)]).
Note that as usual, the output is buffered, so it may need to be flushed
(e.g. explicitly using flush/1).
The output of write/1 is not necessarily in a form acceptable to
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 steam.
- (193) illegal stream specification
- Stream is an illegal stream specification.
?- open(file1,update,s), write(s, X + 2), close(s).
X = _72
?- sh('cat file1').
_72 + 2
write(S, a(b,c)). (Error 4).
write("string", a(b,c)). (Error 5).
write(9, X + 2). (Error 192). % stream not open
write(atom, X + 2). (Error 193).
display / 1, display / 2, get_flag / 2, set_flag / 2, write / 1, writeln / 2, writeq / 1, writeq / 2