4.17.2 ISO Input and Output Streams
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Built-in Predicates
        • Input and output
          • ISO Input and Output Streams
            • open/4
            • open/3
            • open_null_stream/1
            • close/1
            • close/2
            • stream_property/2
            • current_stream/3
            • is_stream/1
            • stream_pair/3
            • set_stream_position/2
            • stream_position_data/3
            • seek/4
            • set_stream/2
            • set_prolog_IO/3
            • set_system_IO/3
    • Packages
Availability:built-in
stream_pair(?StreamPair, ?Read, ?Write)
This predicate can be used in mode (-,+,+) to create a stream-pair from an input stream and an output stream. Mode (+,-,-) can be used to get access to the underlying streams. If a stream has already been closed, the corresponding argument is left unbound. If mode (+,-,-) is used on a single stream, either Read or Write is unified with the stream while the other argument is left unbound. This behaviour simplifies writing code that must operate both on streams and stream pairs.

Stream-pairs can be used by all I/O operations on streams, where the operation selects the appropriate member of the pair. The predicate close/1 closes the still open streams of the pair.99As of version 7.1.19, it is allowed to close one of the members of the stream directly and close the pair later. The output stream is closed before the input stream. If closing the output stream results in an error, the input stream is still closed. Success is only returned if both streams were closed successfully.