eof-object(3scm) Scheme Programmer's Manual eof-object(3scm)

eof-object - return the end-of-file object

(import (rnrs))                     ;R6RS
(import (rnrs io ports))            ;R6RS
(import (rnrs io simple))           ;R6RS
(import (scheme base))              ;R7RS

(eof-object)

Returns an end-of-file object.

Returns a single value which is an end-of-file object.

(eof-object? (eof-object))
          => #t
(eqv? (eof-object) (eof-object))
          => #t    ;R6RS
(eq? (eof-object) (eof-object))
          => #t    ;R6RS

The end-of-file object is used generally to indicate an end-of-file condition. It appears in I/O routines, it is often passed through in parsers, and it is used in generators (e.g. SRFI 158).

Works the same anywhere that it's available. Programs written for earlier reports would sometimes get access to the end-of-file object by using tricks like reading from an empty file or string port.

R6RS has a single unique end-of-file object.

This procedure can raise exceptions with the following condition types:
&assertion (R6RS)
The wrong number of arguments was passed.
R7RS
The assertions described above are errors. Implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically.

eof-object?(3scm)

R6RS, R7RS

First appeared in R6RS and R7RS. Previous reports had eof-object?, but the end-of-file object was not necessarily disjoint from other types.

Other languages take different approaches, such as having the read function return an empty result, or having it return an error and providing a function to test for the end-of-file condition.

This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://weinholt.se/scheme/manpages/.

2021-03-04