Search code examples
common-lisp

What error is signaled when READ-LINE hits EOF?


In the Hyperspec, it says:

If an end of file occurs before any characters are read in the line, an error is signaled if eof-error-p is true.

But it doesn't say what error is signaled. I inferred from How to handle end-of-file error when using read-from-string? that the type is END-OF-FILE, but I don't see that actually written in the Hyperspec anywhere. Am I missing something? Is this implementation-dependent?


Solution

  • The read-line function does return an error of type end-of-file when eof-error-p is true. This is described in the Reader Concepts section of the HyperSpec, 23.1.3.1 The EOF-ERROR-P argument.

    Eof-error-p in input function calls controls what happens if input is from a file (or any other input source that has a definite end) and the end of the file is reached. If eof-error-p is true (the default), an error of type end-of-file is signaled at end of file. If it is false, then no error is signaled, and instead the function returns eof-value....

    It might be worth noting that, while the read-line entry doesn't explicitly say that the error is of type end-of-file, the HyperSpec entry for read does:

    If eof-error-p is true, an error of type end-of-file is signaled at the end of file.