[ Stream I/O | Reference Manual | Alphabetic Index ]

# current_stream(?Stream)

Succeeds if Stream is a currently open stream.

Stream
  Variable, stream handle, or atom.

## Description

Used to test whether a given identifier or handle denotes an open stream, or enumerates all currently open streams on backtracking.

When called with a variable argument, only stream handles are returned, not any symbolic aliases.

### Modes and Determinism

- current_stream(+) is semidet
- current_stream(-) is nondet

### Fail Conditions

Fails if Stream is instantiated but does not denote an open stream.

### Exceptions

(5) type error
  Stream is instantiated, but not to an atom or stream handle.

## Examples

    Success:
        ?- current_stream(S), writeln(S), fail.
        $&(stream,0)
        $&(stream,1)
        $&(stream,2)
        $&(stream,3)
        $&(stream,4)
        $&(stream,5)
        $&(stream,6)
        $&(stream,8)
        No (0.00s cpu)

        ?- current_stream(output).
        Yes (0.00s cpu)

        ?- current_stream(junk).
        No (0.00s cpu)

## See Also

open / 3, open / 4, get_stream_info / 3, get_stream / 2