put-u8(3scm)
π NAME π
Hey bestie, meet put-u8(3scm) β this page is all about put-u8 and write-u8, the little cuties that write a byte to a binary output port. Manual name: put-u8(3scm). Periodt. π
π LIBRARY π
Grab the right import for your vibe:
(import (rnrs)) ;R6RS
(import (rnrs io ports)) ;R6RS
(import (scheme base)) ;R7RS
β¨ SYNOPSIS β¨
(put-u8 binary-output-port byte) ;R6RS
(write-u8 byte) ;R7RS
(write-u8 byte binary-output-port) ;R7RS
π¦ DESCRIPTION π¦
It writes the byte to the given binary-output-port. That's the whole assignment, bestie β no cap. π
π IMPLEMENTATION NOTES π
Chibi Scheme
The current-output-port(3scm) at program start is both textual and binary. It should normally not be possible to use write-u8 on the current output port before rebinding it to a binary output port (which is not possible in R6RS). So yeah, lowkey a little situation there. π
πΈ RETURN VALUES πΈ
R6RS
Returns unspecified values. The vibe is βyou get something, but it's not the main character.β β¨
R7RS
Returns a unspecified value. Yes, exactly like that. π
π§ EXAMPLES π§
;; R7RS code to create a file with the single line "A"
(call-with-port (open-output-file "test.txt")
(lambda (p)
(write-u8 65 p)
(write-u8 10 p)))
π APPLICATION USAGE π
Commonly used in applications that create binary files or other binary data. There is often a mix of single bytes intermixed with larger writes with put-bytevector(3scm). Basically, it's giving βtiny byte, big file energy.β π«Ά
π₯ 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. In particular,bytemust be an exact integer between0and255. So bestie, keep it in range, fr fr. π- 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. Not βfail catastrophicallyβ ππ β that's the actual warning, so don't play with it.
π SEE ALSO π
β STANDARDS β
R6RS, R7RS. Both flavors got a seat at the table. π
π» HISTORY π»
The put-u8 procedure is new to the reworked I/O system introduced with R6RS. The write-u8 procedure is new in R7RS and is similar to write-char(3scm) but works with binary output ports, which did not exist in R5RS. Iconic glow-up behavior, honestly. β¨
π 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/. π«Ά
mwah π β this cutie comes from the Scheme Programmer's Manual, dated 2022-04-07, under put-u8(3scm). byeee bestie! πβ¨
π¦ where this page comes from
- nixpkgs unstable: scheme-manpages 0-unstable-2024-02-11
- π the page's license: MIT
- Copyright (c) 2022 Gwen Weinholt
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms