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 not for both. At any one time there is a current input stream and a current output stream.

Input and output predicates fall into three categories:

  1. those that use the current input or output stream;
  2. those that take an explicit stream argument;
  3. those that use the standard input or output stream -- these generally refer to the user's terminal. Their names begin with tty.

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 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)


  1. At the C level, you can define more general streams, e.g. referring to pipes or to encrypted files (see fli-ios-uds-est).