eof-object(3scm)

πŸ“¦ version 0-unstable-2024-02, in nixpkgs unstable

✨ eof-object β€” return the end-of-file object ✨

okay bestie, so this page is eof-object(3scm) from the Scheme Programmer's Manual, and it's literally the shortest little icon in the whole RnRS-verse. let's get into it πŸ’…


πŸŽ€ LIBRARY

you can import it from any of these, depending on which report you're living your truth under:

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

πŸ¦‹ SYNOPSIS

(eof-object)

that's it. no args. no drama. 🫢

🌸 DESCRIPTION

It returns an end-of-file object. periodt. That's genuinely the whole description. Not me being obsessed with how unbothered this procedure is πŸ’€

πŸ’– RETURN VALUES

Returns a single value, and that single value is an end-of-file object. one value, one vibe, no cap ✨

⭐ EXAMPLES

okay so lowkey the coolest thing here is that the eof object is unique, so it compares equal to itself. watch:

(eof-object? (eof-object))
          => #t

and under R6RS specifically, it's eqv? to itself:

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

and also eq? to itself (again, R6RS energy):

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

the way it just keeps being itself 😭 iconic behaviour honestly πŸ‘‘

🧚 APPLICATION USAGE

So the end-of-file object is used generally to indicate an end-of-file condition. It shows up in I/O routines, it's often passed through in parsers, and it gets used in generators (e.g. SRFI 158). basically it's the "nothing left to read, bestie" signal that travels through your whole pipeline 🌈

🌊 COMPATIBILITY

Works the same anywhere that it's available β€” no surprises. But ngl, there's lore here: 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 πŸ™ˆ

And importantly: R6RS has a single unique end-of-file object. πŸ”₯

πŸ’€ ERRORS

This procedure can raise exceptions with the following condition types:

  • &assertion (R6RS) β€” the wrong number of arguments was passed. like, it takes zero. please don't.
  • 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. yes, catastrophically. ma'am. 😭
bestie, do not pass arguments to a zero-argument procedure and then act surprised. the R7RS option literally includes "fail catastrophically" as a valid outcome πŸ’€

πŸ‘€ SEE ALSO

  • eof-object?(3scm) β€” the vibe check for the eof object πŸŽ€

🌟 STANDARDS

R6RS, R7RS. that's the list, and it ate ✨

πŸ•°οΈ HISTORY

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

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. so many choices and yet here we are, living our truth πŸ’œ

🫢 AUTHORS

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


and that's the whole page, bestie β€” scheme-manpages project, dated 2021-03-04, manual eof-object(3scm). go read something until you hit the eof object, ily, bye πŸ’…πŸ’–πŸŽ€

πŸ“¦ where this page comes from