4.6.7.1 Stream Objects

Each input and output stream is represented by a unique Prolog term, a stream object. In general, this term is of the form

'$stream'(X)
A stream connected to some file. X is an integer.
Atom
A stream alias. Aliases can be associated with streams using the alias(Atom) option of open/4. There are also three predefined aliases:
user_input
An alias initially referring to the UNIX stdin stream. The alias can be changed with prolog_flag/3 and accessed by the C variable SP_stdin.
user_output
An alias initially referring to the UNIX stdout stream. The alias can be changed with prolog_flag/3 and accessed by the C variable SP_stdout.
user_error
An alias initially referring to the UNIX stderr stream. The alias can be changed with prolog_flag/3 and accessed by the C variable SP_stderr. This stream is used by the Prolog top-level and debugger, and for all unsolicited messages by built-in predicates.

Stream objects are created by the predicate open/[3,4] ref-iou-sfh-opn and passed as arguments to those predicates that need them. Representation for stream objects to be used in C code is different. Use stream_code/2 to convert from one to the other when appropriate.


Send feedback on this subject.