4.6.2 About Streams

A Prolog stream can refer to a file or to the user's terminal1. Each stream is used either for input or for output, but typically not for both. A stream is either text, for character and term I/O, or binary, for byte I/O. At any one time there is a current input stream and a current output stream. Input and output predicates fall into two categories:

  1. those that use the current input or output stream;
  2. those that take an explicit stream argument;

Initially, the current input and output streams both refer to the user's terminal. Each input and output built-in predicate refers implicitly or explicitly to a stream. The predicates that perform byte, character and term I/O operations come in pairs such that (A) refers to the current stream, and (B) specifies a stream.

          predicate_name/n (A)
          predicate_name/n+1 (B)

Footnotes

[1] At the C level, you can define more general streams, e.g. referring to pipes or to encrypted files.



Send feedback on this subject.