make-bytevector - create a new bytevector
(import (rnrs)) ;R6RS
(import (rnrs bytevectors)) ;R6RS
(import (scheme base)) ;R7RS
(make-bytevector k fill)
Return a newly allocated bytevector of
argument is missing, the initial contents of the returned bytevector
argument is present, it must be an exact integer object. Every byte in
the returned bytevector will be set to this value.
argument must be in the range [−128, 255]. If
is positive, it is interpreted as if passed to
If it is negative, it is instead used as if passed to
argument must be in the range [0, 255].
- Chez Scheme, Loko Scheme, (others?)
is zero then the empty bytevector object is returned.
- GNU Guile, Loko Scheme, (others?)
is missing then the bytevector is initialized to zeros.
- Chibi Scheme
Even though Chibi is an R7RS implementation, the
argument is interpreted as in R6RS. This is a valid extension of R7RS.
Returns a single object which is a bytevector object of the given
is non-zero then the bytevector is fresh. If
is zero then the unique empty bytevector object may be returned.
(make-bytevector 2 12)
=> #u8(12 12) ;R7RS notation
This procedure is used in code that works with mutable bytevectors.
For some code an alternative is to use
and to build the data sequentially.
Portable code should provide the second argument, and should keep it
in the range [0, 255].
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.
- &implementation-restriction (R6RS)
There is not enough free memory to hold the new bytevector.
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.
This page is part of the
It includes materials from the RnRS documents.
More information can be found at
It is often a mistake to call this procedure without the
argument. Unusual values of
can stress the Scheme implementation's memory allocator and cause a
Markup created by unroff 1.0sc, March 04, 2023.