bytevector-copy! - copy bytes between bytevectors
LIBRARY
(import (rnrs)) ;R6RS
(import (rnrs bytevectors)) ;R6RS
(import (scheme base)) ;R7RS
SYNOPSIS
(bytevector-copy! source source-start target target-start k) ;R6RS
(bytevector-copy! to at from start end) ;R7RS
DESCRIPTION
- R6RS
-
Copies the bytes from
source at indices
source-start, …, source-start + k − 1
to consecutive indices in target starting at target-index.
- R7RS
-
Copies the bytes of bytevector from between start and end
to bytevector to, starting at at.
RETURN VALUES
Returns unspecified values.
EXAMPLES
;; R6RS
(let ((b (u8-list->bytevector '(1 2 3 4 5 6 7 8))))
(bytevector-copy! b 0 b 3 4)
(bytevector->u8-list b))
=> (1 2 3 1 2 3 4 8)
;; R7RS
(define a (bytevector 1 2 3 4 5))
(define b (bytevector 10 20 30 40 50))
(bytevector-copy! b 1 a 0 2)
=> #u8(10 1 2 40 50)
APPLICATION USAGE
This procedure is common in (de)serialization and processing of binary
data. In some situations it becomes cumbersome to maintain the indices
and bytevector ports are more suitable.
COMPATIBILITY
R6RS and R7RS specify very different arguments for these procedures.
Note in particular that it's not just a different argument order, the
last argument is also different.
ERRORS
This procedure can raise exceptions with the following condition types:
- &assertion (R6RS)
-
The wrong number of arguments was passed, an argument was outside its
domain or the byte ranges were not valid with regard to the bytevector
lengths.
- 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.
SEE ALSO
bytevector-copy(3scm)
STANDARDS
R6RS,
R7RS
HISTORY
The arguments used by R7RS are consistent with SRFI-43 whereas R6RS is
consistent with SRFI-66.
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/
.
BUGS
Implementations need to be careful to handle the case where the source
and target bytevector ranges overlap in memory.
Markup created by unroff 1.0sc, March 04, 2023.