The package for implicit input and output destination is upwards
compatible to DEC-10 and C-Prolog. The reading and writing predicates
refer to resp. the current input- and output stream. Initially these
streams are connected to the terminal. The current output stream is
changed using tell/1
or append/1.
The current input stream is changed using see/1.
The streams current value can be obtained using telling/1
for output- and seeing/1
for input streams. The table below shows the valid stream
specifications. The reserved names user_input
,
user_output
and user_error
are for neat
integration with the explicit streams.
user | This reserved name refers to the terminal |
user_input | Input from the terminal |
user_output | Output to the terminal |
user_error | Unix error stream (output only) |
<Atom> | Name of a Unix file |
pipe(<Atom> | Name of a Unix command |
Source and destination are either a file, one of the reserved words above, or a term `pipe(Command)'. In the predicate descriptions below we will call the source/destination argument `SrcDest'. Below are some examples of source/destination specifications.
?-
see(data). | %Start reading from file `data'. |
?- tell(stderr). | %Start writing on the error stream. |
?- tell(pipe(lpr)). | %Start writing to the printer. |
Another example of using the pipe/1 construct is shown below. Note that the pipe/1 construct is not part of Prolog's standard I/O repertoire.