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

bit or byte?

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

Nice thing!

It is a controversial thing, but it is also important:

    Why is the smallest addressable unit in a blob an octet and not a bit?

We should think about the implications first, but I think it will be a great
benefit if this SRFI would be bit-accurate instead of byte-accurate.
The benefits of bit-accurate blobs are (among others):
1. They are occasionally useful as a data type themselves, e.g. for representing
subsets of a fixed finite set.
2. Many binary format specifications (e.g. in communication systems, networking,
image compression, ...) are specified in terms of not necessarily byte-aligned bit
fields. Implementing bit-accurate access on top of bytes is error prone and tedious.
(I know everything about that from communication system standards.)

The cost of being bit-accurate are as follows:
* Implementations might be tempted to represent the length as a FIXNUM. If
this is design is chosen, and immediate integers are 30-bits, the maximal blob is
just 64 MByte. This will very likely turn out to be a problem one day.
* The implementation is substantially complicated. In particular the COPY!
operation is not an easy thing to write if it is to be efficient. (I did do that for Ocaml.)
* Users might forget that they have to multiply the length by 8 to get bytes.

Note that the actual execution speed is unaffected since blob-operations that are
byte- or word-aligned can (and should) be recognized as special cases.