Accessing and redirecting the stream aliases

Author(s): Manuel Carro.

This library allows the redefinition of the files to which the special streams user_input, user_output, and user_error point to. On startup they point to the standard input, standard output, and standard error, in Unix style (Windows users may find that standard error stream does not work properly). Changing the file pointed to is useful for, e.g., redirecting the place to which the Prolog's standard error stream goes from within Prolog (e.g., to start a log file).

Usage and interface

Documentation on exports

PREDICATE

Usage:set_stream(StreamAlias,NewStream,OldStream)

Associate StreamAlias with an open stream newStream. Returns in OldStream the stream previously associated with the alias. The mode of NewStream must match the intended use of StreamAlias.

  • The following properties should hold at call time:
    (term_typing:nonvar/1)StreamAlias is currently a term which is not a free variable.
    (term_typing:nonvar/1)NewStream is currently a term which is not a free variable.
    (streams_basic:stream_alias/1)StreamAlias is the alias of an open stream, i.e., an atom which represents a stream at Prolog level.
    (streams_basic:stream/1)NewStream is an open stream.
    (streams_basic:stream/1)OldStream is an open stream.

PREDICATE

Usage:get_stream(StreamAlias,Stream)

Return in Stream the stream associated with StreamAlias.

  • The following properties should hold at call time:
    (term_typing:nonvar/1)StreamAlias is currently a term which is not a free variable.
    (streams_basic:stream_alias/1)StreamAlias is the alias of an open stream, i.e., an atom which represents a stream at Prolog level.
    (streams_basic:stream/1)Stream is an open stream.