eof-object?(3scm)
hey bestie, this is the eof-object? page from the Scheme Programmer's Manual π
πΈ NAME πΈ
eof-object? β test if an object is the end-of-file object
π LIBRARY π
These imports are your VIP passes, depending on which Scheme situation you're in:
(import (rnrs)) ;R6RS
(import (rnrs io ports)) ;R6RS
(import (rnrs io simple)) ;R6RS
(import (scheme r5rs)) ;R7RS
(import (scheme base)) ;R7RS
β¨ SYNOPSIS β¨
(eof-object? obj)
π DESCRIPTION π
Okay so this is the vibe check for EOF objects. It returns #t if obj is an end-of-file object, and otherwise it returns #f.
The end-of-file object is literally what various I/O procedures hand back when they reach end of file. Yes bestie, that's the whole point.
π RETURN VALUES π
Returns a single boolean object. One boolean, no drama.
π¦ EXAMPLES π¦
(eof-object? (eof-object))
=> #t
(eof-object? #\space)
=> #f
π APPLICATION USAGE π
This procedure is used on the result of I/O read operations, like read(3scm), to see if the port has an end-of-file condition. It also shows up in the context of generators (e.g. SRFI 158). Slay.
π§ COMPATIBILITY π§
There is a slight difference between R6RS and the other reports. Not me having lore:
R4RS, IEEE Scheme, R5RS, R7RS
The precise set of end-of-file objects will vary among implementations, but in any case no end-of-file object will ever be an object that can be read in using read.
If an object satisfies this predicate, it does not satisfy any of these predicates: boolean?, bytevector?, char?, null?, number?, pair?, port?, procedure?, string?, symbol?, vector?, or any record type predicate. Periodt.
R6RS
There is a unique end-of-file object. (This also satisfies the R7RS requirements).
π ERRORS π
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. Yes, catastrophically. π
π₯ SEE ALSO π₯
π STANDARDS π
R4RS, IEEE Scheme, R5RS, R6RS, R7RS
π«Ά HISTORY π«Ά
This procedure was unchanged in Scheme from R2RS (AI Memo No. 848, 1985) until R6RS, which is when the end-of-file object become a unique object for the first item. R7RS branched off from R5RS and did not adopt the R6RS semantics for this object.
LISP 1.5 had an end-of-file character that printed as $EOF$ and an end-of-record character that printed as $EOR$. PDP-10 MacLISP had an optional other argument to read that let the program specify its own end-of-file object. Scheme before R2RS would have used this implementation of read. The lore is lowkey iconic.
π 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/.
This page is eof-object?(3scm) from the Scheme Programmer's Manual, dated 2021-03-05 β bye bestie, go check those EOF vibes ππ
π¦ 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