A bytevector is an object that contains a sequence of bytes, that is,
exact integers between 0 and 255 inclusive. A bytevector has a length
that is fixed at creation time, and as many bytes, indexed from
length-1. Compared to vectors, bytevectors use
less size for each element.
Bytevectors may be mutable or immutable. If an attempt is made to mutate an immutable bytevector, an error is signaled. Two immutable bytevectors are “eq?” iff they are “equal?”. Two mutable bytevectors are “eq?” if they were created by the same constructor call. Two mutable bytevectors are “equal?” iff they have the same length and have “equal?” bytes in each position. There is only one empty bytevector (that is, a bytevector of length 0) and that bytevector is immutable. The bytevector type is encapsulated.
SOURCE NOTE: The report doesn't currently include bytevectors. They are taken from r7rs scheme.
The primitive type predicate for type bytevector.
bytevector?returns true iff all the objects in
objectsare of type bytevector.
The primitive type predicates for types immutable bytevector and mutable bytevector. These return true iff all the objects in
objectsare of type immutable bytevector or mutable bytevector respectively.
make-bytevectorconstructs and returns a new mutable bytevector of length
u8is specified, then all bytes in the returned bytevector are
obj, otherwise the content of the bytevector is unspecified.
bytevector-lengthreturns the length of
bytevector-refreturns the byte of
kis out of bounds (i.e. less than
0or greater or equal than
(bytevector-length bytevector)) an error is signaled.
bytevector-set!replaces the byte with index
kis out of bounds, or
bytevectoris immutable, an error is signaled. The result returned by
bytevectorcontructs and return a new mutable bytevector composed of the byte arguments.
These applicatives convert between bytevectors and lists of bytes. If the list passed to
list->bytevectorcontains an object that isn't a byte, an error is signaled. The objects returned by these applicatives are always mutable.
bytevector-copyconstructs and returns a new mutable bytevector with the same length and bytes as
These applicatives convert between bytevectors and vectors. If a vector containing objects other than bytes (exact integers between 0 and 255 inclusive) is passed to
vector->bytevector, an error is signaled. The objects returned by these applicatives are always mutable.
bytevector2 should have a length greater than or equal to that of bytevector1.
Copies the bytes in bytevector1 to the corresponding positions in bytevector2. If bytevector2 is immutable, an error is signaled. The result returned by
k2should be valid indexes in
bytevector. Also it should be the case that
k1 <= k2.
bytevector-copy-partialconstructs and returns a new mutable bytevector with length
k2 - k1, with the bytes from
bytevector, starting at index
k1(inclusive) and ending at index
k2-1should be valid indexes in
bytevector1. Also it should be the case that
k1 <= k2. Both
k3 + (k2-k1) - 1should be valid indexes in
bytevector-copy-partial!copies bytes k1 (inclusive) through k2 (exclusive) from
bytevector2is an immutable bytevector, an error is signaled. The result returned by
bytevector-fill!replaces all the bytes in
bytevectoris an immutable bytevector, an error is signaled. The result returned by