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


Back up one character on Stream
Stream handle or alias (atom)


Go back one character on the given Stream. This can be used to implement lookaheads.

The number of characters that can be reliably ungotten is 4, and the result is only defined if these characters have been read previously.

The result of the operation is undefined if

In these cases, unget/1 will succeed, but subsequent read operations will return undefined results.

Modes and Determinism


(4) instantiation fault
Stream is not instantiated.
(5) type error
Stream is neither a stream handle nor an atom.
(192) illegal stream mode
Stream not in read mode.


% look ahead one character in Stream:

    peek(Stream, X) :-
        get(Stream, X),

See Also

get / 2, get_char / 2