Bytevectors

A bytevector is a data structure that stores bytes -- exact 8-bit unsigned integers. Bytevectors are useful in constructing system interfaces and other low-level programming. In Larceny, many bytevector-like structures -- strings, bignums, and even bytevectors themselves -- are implemented in terms of a lower-level bytevector-like data type. The operations on generic bytevector-like structures are particularly fast but useful largely in code that manipulates Larceny's data representations.

Integrable procedure make-bytevector

(make-bytevector length) => bytevector

Returns a bytevector of the desired length. The bytevector has not been initialized and most likely contains garbage. To initialize the bytevector uniformly, use bytevector-fill! (below); there is no optional initalization value.

Operations on bytevector structures

(bytevector? obj) => boolean
(bytevector-length bytevector) => integer
(bytevector-ref bytevector offset) => byte
(bytevector-set! bytevector offset byte) => unspecified
(bytevector-equal? bytevector1 bytevector2) => boolean
(bytevector-fill! bytevector byte) => unspecified
(bytevector-copy bytevector) => bytevector

These procedures do what you expect. All procedures are integrable, except bytevector-equal? and bytevector-copy.

Operations on bytevector-like structures

(bytevector-like? bytevector) => boolean
(bytevector-like-length bytevector) => integer
(bytevector-like-ref bytevector offset) => byte
(bytevector-like-set! bytevector offset byte) => unspecified
(bytevector-like-equal? bytevector1 bytevector2) => boolean
(bytevector-like-copy bytevector) => bytevector

A bytevector-like structure is a low-level representation on which data that are indexable like bytevectors are built, e.g., bytevectors, strings, bignums, and flonums.

There is no way of constructing a "generic" bytevector-like structure; use the constructors for the data mapped onto bytevector-like structures instead, like make-string or make-bytevector.

The bytevector-like operations operate on all bytevector-like structures. All the procedures are integrable, except bytevector-like-equal? and bytevector-like-copy.


$Id: bytevectors.html,v 1.5 2000/09/12 02:46:45 lth Exp $
larceny@ccs.neu.edu