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. This procedure treats bytevector as potentially containing more than one type.
(<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 the size of the binary value in bytes. This procedure treats bytevector as a uniformly typed vector.
(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. This procedure treats bytevector as potentially containing more than one type.
(<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 the size of the binary value in bytes. This procedure treats bytevector as a uniformly typed vector.
(<type><endian>vector-length bytevector)
Returns a Scheme number corresponding to length of bytevectordivided by the size of the binary value in bytes.
The types are:
The endianism values are:
Endianism is not applicable to the u8 and s8 types.
TBD