get-bytevector-all(3scm)
β¨ get-bytevector-all β read bytes until the next end of file β¨
okay so this is get-bytevector-all(3scm), from the Scheme Programmer's Manual (3scm section, bestie π
). it lives in the scheme-manpages universe and honestly? it's giving "one job, does it perfectly." let's get into it π«Ά
πΈ LIBRARY πΈ
(import (rnrs)) ;R6RS
(import (rnrs io ports)) ;R6RS
two ways to import, same energy. pick your fave, they both slay π
β¨ SYNOPSIS β¨
(get-bytevector-all binary-input-port)
one argument. one port. no drama. π
π DESCRIPTION π
so what does it do? it reads all the bytes until the next end of file. that's it. that's the whole vibe. and yes, it blocks as necessary β it'll sit there and wait like a loyal bestie π«Ά
here's the tea, three scenarios:
- if one or more bytes get read β you get back a bytevector containing all the bytes up to the next end of file, and
binary-input-portgets updated to point just past those bytes π - if no bytes get read β you get the end-of-file object back. nothing. nada. the void. π
β οΈ heads up bestie: this operation may block indefinitely waiting to see if more bytes will become available β even if some bytes are already available. so like, it's committed to the bit. no cap. π
π RETURN VALUES π
returns a single value, which is either a bytevector or the end-of-file object. that's the whole menu. π
π¦ EXAMPLES π¦
(call-with-port (open-file-input-port "/etc/machine-id")
get-bytevector-all)
slurp an entire file in one clean line. iconic. no loop, no mess, just vibes β¨
π APPLICATION USAGE π
this procedure is a convenience β it replaces a loop that is, and I quote, "fiddly to make efficient and correct." so basically someone already did the hard part for you, and you get to be lazy about it. we love that for us π
π COMPATIBILITY π
this procedure is unique to R6RS. so likeβ¦ it's not everywhere. check before you assume, iykyk π
π₯ ERRORS π₯
this procedure can raise exceptions with the following condition types:
&assertion(R6RS) β the wrong number of arguments was passed, or an argument was outside its domain. classic. π- 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. that's the real word. no cap ππ₯
π SEE ALSO π
(yes there's a trailing comma in the original list, we're keeping it, character for character, that's just how it is π)
π§ STANDARDS π§
R6RS β that's the whole standard section. short and sweet. β
π HISTORY π
this procedure first appeared in the reworked I/O system in R6RS. so it's a glow-up baby. main character energy from day one π
π AUTHORS π
this page is part of the scheme-manpages project. it includes materials from the RnRS documents. more info can be found at https://github.com/schemedoc/manpages/. π«Ά
and that's the whole page, bestie!! πΈ written by the scheme-manpages girlies, dated 2023-02-01, served fresh from the Scheme Programmer's Manual, get-bytevector-all(3scm). mwah πβ¨
π¦ where this page comes from
- nixpkgs unstable: scheme-manpages 0-unstable-2024-02-11
- π the page's license: MIT
- Copyright (c) 2023 Gwen Weinholt
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms