Prolog /
IsoIoI/O built-ins and EOFAccording to ISO 13211-1, input streams have an end_of_stream property, which can take the values not, at and past. It also defines the stream option eof_action(...) in section 7.10.2.11. The name is misleading, as it actually specifies the behaviour when the stream is past (rather than at) eof:
The default is implementation-defined, possibly different for different streams. In ECLiPSe,
ECLiPSe actually closes the stream after reporting the past_end_of_stream error.
It seems to make sense for read_string/5 to leave the stream in past-eof position when -1 was returned as the separator. For read_string/3, if the stream contains less characters than requested, should it leave the stream at or past eof? As no separator is consumed in this case, it should be at. Reading from a stream in at-eof position could return "" or fail (as read_string/4 does). EDIT 2019: It is more convenient for read_string/3,5 to once return "",-1 at eof. |