[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

#<byte>?



Question: why doesn't MzScheme have a byte type? Programs generally seem
to use chars (and char->integer) to deal with byte-oriented binary data,
but this is not an ideal solution in a world of multi-byte character
sets (such as UNICODE). The char type should (according to R5RS)
abstract the idea of individual symbols used for communication, not
binary data of a certain number of bits. R5RS makes no mention of the
storage size of chars, thereby rendering code that counts on 1-byte
characters unportable. (At least the storage size of a byte type would
be certain, and you'd KNOW if a Scheme system didn't support it. If you
run a program on a Scheme implementation that uses 2-byte UNICODE
characters instead of ASCII, your program's behavior is uncertain, and
will probably fail.)  <insert my CS prof's speech about faulty code
causing airplanes to crash here>

I realize that Scheme generally tries to separate the programmer from
the internal representation of data, but the ability to manipulate
vectors of bytes would be quite powerful. It would allow Scheme code to
conveniently deal with industry-standard media formats (and further
suppress the myth that Scheme is an impractical academic language).
Bytes wouldn't have to be considered numbers, since they really just
represent bit sequences, not necessarily integers. Of course it would
probably be nice to have byte->integer and integer->byte (as well as
unsigned-byte->integer and integer->unsigned-byte) for practical
reasons. Perhaps some operators for bit shifting and masking would also
be helpful.

If you're participating in the ICFP contest (I believe the problem will
be issued around 5pm EST today), good luck!!

-John