bytevector(3scm)

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

πŸ’… bytevector β€” bestie's guide to making bytes

okay so first things first: this page lives in the Scheme Programmer's Manual (yes the whole manual, we're fancy like that ✨) and this one little entry is all about bytevector.

πŸ“š LIBRARY

(import (scheme base))              ;R7RS

that's the import, periodt. if you want this procedure you gotta pull in (scheme base) and that comment right there says it's R7RS flavored πŸ’–


✨ SYNOPSIS ✨

(bytevector byte ...)

that's it. that's the whole vibe. you hand it some bytes, it hands you back a bytevector 🫢

🌸 DESCRIPTION 🌸

Returns a newly allocated bytevector containing its arguments. like, fresh out the box, brand new, nobody else's bytevector, it's giving main character energy πŸ‘‘

πŸ’« RETURN VALUES πŸ’«

Returns a single bytevector object. one (1) bytevector. that's the whole return situation, no cap πŸŽ€

πŸ”₯ EXAMPLES πŸ”₯

(bytevector 1 3 5 1 3 5)  =>  #u8(1 3 5 1 3 5)
(bytevector)              =>  #u8()

look at that first one β€” 1 3 5 1 3 5, iconic pattern, ate πŸ’… and the second one? no args, no bytes, still a perfectly valid empty bytevector #u8(). we love a zero-argument queen πŸ™ˆ

πŸ¦‹ COMPATIBILITY πŸ¦‹

heads up bestie β€” this procedure is absent from R6RS 😭 like it literally does not exist there. if you're on R6RS, use u8-list->bytevector(3scm) instead, iykyk.

πŸ’€ ERRORS πŸ’€

It is an error if one of the arguments is not an exact integer object in the range from 0 to 255 inclusive. so like, 0 through 255, nothing else, don't try it 🚫

and here's the chaotic part β€” implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically 😭😭😭 that last one is real, the manpage literally says that. so yeah, lowkey don't pass it a bad value unless you're feeling brave.

fr fr, "fail catastrophically" is not a drill. keep your bytes between 0 and 255 inclusive πŸ”΄

πŸ‘€ SEE ALSO πŸ‘€

⭐ STANDARDS ⭐

R7RS β€” that's the standard, that's the source of truth, that's the ~vibe~ 🌈

🧚 HISTORY 🧚

This procedure first appeared in R7RS. so like... it wasn't in R6RS (which we already established, but the history section is confirming it, consistency queen πŸ’œ)

πŸ‘‘ 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/ β€” go check it out, the whole squad is there πŸ“


and that's the page bestie!! πŸ’– source + version: this is a 3scm page from the scheme-manpages project, dated 2021-02-28. stay bytey, stay valid, stay in that 0–255 range πŸŽ€βœ¨

πŸ“¦ where this page comes from