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

Re: If you like "u8vector" ...

This page is part of the web mail archives of SRFI 66 from before July 7th, 2015. The new archives for SRFI 66 contain all messages, not just those from before July 7th, 2015.

"Moiself" == Michael Sperber <sperber@xxxxxxxxxxxxxxxxxxxxxxxxxxx> writes:

Moiself> I haven't done anything yet wrt. the naming issue---that's still
Moiself> pending.  I'd like to hold a little poll.  For that, it'd be helpful
Moiself> if the camp in favor of "u8vector" could suggest names for what's
Moiself> currently READ-BYTE, READ-BYTES, and READ-BYTES-N in SRFI 68.

One factor is that if you have binary I/O you might want to read other
kinds of binary numbers and just byte arrays:  A picture might be an
array of 32-bit integers, for example.  The "java.nio" package
introduced in JDK 1.4 does support reading/writing uniform arrays that
are not bytes, so this is not a complete fanciful idea.

So using a name like read-u8-n generalizes to read-u32-n in a way that
read-byte-n doesn't.

Though I don't think I'd often read a vector of u32, I think reading a
single u32 a common operation.  Many binary files formats have 16-bit
or 32-bits values.  Of course there are byte-order issues - see below.

So I suggest renaming read-byte to read-u8.

I'm afraid I'm not sure I understand the distinction between input-bytes
and input-bytes-all:  the spec says input-bytes-all may block
indefinitely on streams connected to interactive readers, but doesn't
say that about input-bytes - is that an oversight?

A name suggestion, if I'm understanding this right:
input-bytes -> input-u8-some and input-bytes-all -> input-u8-all.
The reverse is also possible: input-some-u8 and input-all-u8.
If so: read-bytes -> read-u8-some/read-some-u8 and
read-bytes-all -> read-u8-all/read-all-u8.

We might also consider:
read-u32le/input-u32le: read a little-endian 32-bit unsigned int.
(or read-u32-le or read-u32l.)
read-u32be/input-u32be: read a big-endian 32-bit unsigned int.
Likewise for u16/s16/s32/... etc.

We might also consider:
read-u32: either read-u32le or read-u32be, depending on whether the
port is in little-endian or big-endian mode, which might be settable.
	--Per Bothner
per@xxxxxxxxxxx   http://per.bothner.com/