This is a proposal for a WG2 bytevector API. The conceit is that everything is a separate procedure with minimal arguments; this makes for a lot of procedures, but each one can be easily inlined by even a very dumb compiler, providing high efficiency.
(bytevector-<type><endian>-ref bytevector n)
Returns a Scheme number corresponding to the binary value encoded according to type beginning at offset n in bytevector.
(<type><endian>vector-ref bytevector n)
Returns a Scheme number corresponding to the binary value encoded according to type beginning at offset n in bytevector, where n is first multiplied by a value corresponding to the size of the binary value.
(bytevector-<type><endian>-set! bytevector n v)
Converts v to a binary value encoded according to type and places it into bytevector beginning at offset n.
(<type><endian>vector-set! bytevector n v)
Converts v to a binary value encoded according to type and places it into bytevector beginning at offset n, where n is first multiplied by a value corresponding to the size of the binary value.
(<type><endian>vector-length bytevector)
Returns a Scheme number corresponding to length of bytevectordivided by a value corresponding to the size of the binary value.
The types are:
The endianism values are:
Endianism is not applicable to the u8 and s8 types.
TBD