eof-object(3scm)
β¨ 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
- nixpkgs unstable: scheme-manpages 0-unstable-2024-02-11
- π the page's license: MIT
- Copyright (c) 2021 Gwen Weinholt
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms