Suppose I have an empty file (imaginatively called empty
) in the current directory and run the following query.
Using SICStus Prolog 4.7.1 (Intel x86-64):
| ?- open(empty,read,S,[eof_action(eof_code)]), stream_property(S,end_of_stream(EOS0)), peek_char(S,_), stream_property(S,end_of_stream(EOS1)), get_char(S,_), stream_property(S,end_of_stream(EOS2)), peek_char(S,_), stream_property(S,end_of_stream(EOS3)), peek_char(S,_), stream_property(S,end_of_stream(EOS4)), close(S). S = '$stream'(140253160396048), EOS0 = not, EOS1 = at, EOS2 = past, EOS3 = at, EOS4 = at ?
With peek_char
and get_char
the stream property end_of_stream
goes from not
to at
to past
—I get that.
But another peek_char
makes it step back from past
to at
—That got me:)
What's going on? I was expecting the property to remain at past
...