bytevector-fill!(3scm)
π bytevector-fill!(3scm) π
okay so bestie, welcome to the Scheme Programmer's Manual β yes that's the actual manual name, she's fancy, we love her β and today's main character is bytevector-fill!. Buckle up π
β¨ NAME β¨
bytevector-fill! β fill a bytevector with a value. that's it. that's the whole gig. and she ate π
π LIBRARY π
import her like this, depending on your era:
(import (rnrs)) ;R6RS
(import (rnrs bytevectors)) ;R6RS
π¦ SYNOPSIS π¦
(bytevector-fill! bytevector fill)
πΈ DESCRIPTION πΈ
so what she does is: this procedure stores fill in every single element of bytevector. every one. no cap. π―
the fill value has to be an exact integer living in the interval [-128, 255]. and the negative fill values? they get interpreted as bytes, viz.:
(bytevector-fill! bytevector (bitwise-and fill #xff))
π«Ά RETURN VALUES π«Ά
returns unspecified values. she gives you nothing back, she's mysterious like that π
β EXAMPLES β
(let ((a (u8-list->bytevector '(1 2 3))))
(bytevector-fill! a 0)
a)
=> #vu8(0 0 0)
see how she just zeroed the whole thing out? iconic π
π APPLICATION USAGE π
ok so this one's kinda the "responsible bestie" move: this procedure is sometimes useful to clear sensitive parts of memory, like bytevectors holding cryptographic keys. π
but bestie listen β this is optimistic but is not in any way guaranteed to wipe the data from memory. π so like, don't @ me if your keys are still lurking, fr fr.
also, heads up: a bytevector that contains the specified value would normally be created from scratch with make-bytevector(3scm).
π COMPATIBILITY π
the only difference in behavior between implementations should be in how fast it runs. that's it. that's the drama. and just so you know β this procedure is not present in R7RS-small. π«
π ERRORS π
she can raise exceptions with the following condition types:
&assertion(R6RS) β the wrong number of arguments was passed or an argument was outside its domain. basically: you fumbled the input, bestie π€·ββοΈ
π₯ SEE ALSO π₯
vector-fill!(3scm)make-bytevector(3scm)
π STANDARDS π
R6RS β
π§ 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 vibe check, bestie π mwah, go fill those bytevectors responsibly β this page is from 2021-02-23 and it's bytevector-fill!(3scm) all day, every day πβ¨
π¦ 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