Next: mpg-ref-atom, Previous: mpg-ref-at_end_of_line, Up: mpg-bpr [Contents][Index]
at_end_of_stream/[0,1]
ISOat_end_of_stream
at_end_of_stream(+Stream)
Tests whether the end has been reached for the current input stream or for the input stream Stream.
stream_object, must be ground
A valid Prolog input stream, defaults to the current input stream.
Checks if the end has been reached for the specified input stream. An input stream reaches the end when all items (characters or bytes) except ‘EOF’ (-1) of the stream have been read. It remains at the end after ‘EOF’ has been read.
Stream errors (see ref-iou-sfh-est).
at_end_of_stream/[0,1]
peeks ahead for next input item if there is
no item available on the buffer of the specified input stream.
Note that at_end_of_stream/[0,1]
never blocks. If reading ahead
would block, then at_end_of_stream/[0,1]
will fail, even if the
stream is actually at its end. If you want to ensure that end-of-stream
condition is always properly detected, even if that entails blocking
until further input is possible, then you can use peek_code/[1,2]
or
peek_byte/[1,2]
.
Please note: The design of
at_end_of_stream/[0,1]
makes it inherently unreliable. It is present only for ISO standards compliance. It is better to read or peek until one of the end of file indications is returned.
at_end_of_line/[0,1]
.