[r6rs-discuss] Bytevectors

r6rsguy at free-comp-shop.com r6rsguy at free-comp-shop.com
Tue Jun 19 02:07:13 EDT 2007


Megadittos R6RS!  Long time reader, first time writer.

I am concerned that the syntax #vu8(...) for a bytevector
is irregular, hard to remember, and ugly.  It seems to have
been taken (sort of) from SRFI-4, but _none_ of the rest
of SRFI-4 is specified.  Indeed, SRFI-4 says that the external
representation of a bytevector should be #u8(...). without the
#\v, and that the various procedures have names like u8vector?
and u8vector-set!

But the name of these objects has been changed to "bytevector",
why not write the external representation as #bytevector(...)?
That is a little bit longer, but not longer than any of the 
names of procedures that operate on bytevectors.

Also, the report says that bytes are in the range {-128..127},
yet <bytevector> -> #vu8(<u8>*),
 where <u8> -> <number> in {0..255}.

Surely, that should be <bytevector> -> #bytevector(<eight bits>*)
 where <eight bits> -> <number> in {-128..255} with the
same convention as the fill parameter of make-bytevector.

I suggest that the following name changes would improve euphony:
bytevector-u8-ref   to  octetvector-ref
bytevector-s8-ref   to  bytevector-ref
bytevector-u8-set!  to  octetvector-set!
bytevector-s8-set!  to  bytevector-set!
bytevector->u8-list to  octetvector->list
u8-list->bytevector to  list->bytevector

list->bytevector is modified to accept a list of integers
in the range {-128..255} with the usual interpretation of
negative numbers (mod 256).

new procedure:
(bytevector->list <bytevector>) similar to octetvector->list,
but returns a list of integers in the range {-128..127}
There seems to be no procedure bytevector->s8-list, which
would be the natural name of this procedure in the R5.94
system.

If the size and endianness parameters on
bytevector-uint-ref, bytevector-sint-ref, bytevector-uint-set!,
and bytevector-sint-set! were reversed, then dropping the last
parameter (endianness) could result in using the native
endianness.

Finally, since I am on a roll, I suggest that the entire
set of operations on 16, 32, and 64 bit integers could
be dropped.  All those are shorter to write with the
-uint- and -sint- procedures with a size parameter.
For example, instead of (bytevector-u64-native-ref bv k)
say (bytevector-uint-ref bv k 8). 

That completes the elimination of digits in the names of
bytevector procedures.

  -- Keith



More information about the r6rs-discuss mailing list