peek_char/[1,2]

Synopsis

peek_char(-Char)

peek_char(+Stream, -Char)

looks ahead for next input character on the current input stream or on the input stream Stream.

Arguments


Stream stream_object
a valid Prolog stream.
Char char
the resulting next input character available on the stream.

Description

peek_char/[1,2] looks ahead of the next input character of the specified input stream and unifies the character with Char. The peeked character is still available for subsequent input on the stream.

Example

<<NEEDS EXAMPLE>>

Exceptions

Stream errors (see ref-iou-sfh-est), plus:


existence_error
This is an attempt to read past end of file, or some operating system dependent error occurred in reading.

Comments

It is safe to call peek_char/[1,2] several times without actually inputting any character. For example:

     | ?- peek_char(X), peek_char(X), get0(X).
     |: a
     
     X = 97
     

See Also

get0/[1,2], get/[1,2], open/[3,4] ref-iou