My general idea so far is to have a bit generator/accumulator built on top of a binary input/output port which takes care of the buffering between bits and bytes for you.  Generators and accumulators are much more flexible than ports, which need non-portable coding (except on R6RS) to extend them.  Indeed, <https://bitbucket.org/cowan/r7rs-wg1-infra/src/default/PortOperationsCowan.md> is a portable SRFI for converting Scheme read and write operations cheaply to generators and accumulators.

On Sat, Dec 28, 2019 at 9:09 PM Arne Babenhauserheide <xxxxxx@web.de> wrote:

Lassi Kortela <xxxxxx@lassi.io> writes:

>> I implemented a Hamming-code with Scheme last year, and I’m missing the
>> hardest part from this SRFI: How to read a file into a bitvector which
>> does not have bits that are a multiple of 8? How to write such a
>> bitvector to a file?
>
> I.e. an option to drop all the parity bits on read/write?

Something simpler: How to read a file and write it hamming-encoded?

How to read from a port and write a hamming-encoded bitstream to another
port?

How to decode (and fix) hamming-encoded data from a port and write it to
another one?

This is for teaching people networking code.

Something like:

 (match (bitvector->list (bitvector-get! readport 11))
        ((p1 p2 d3 p4 d5 d6 d7 p8 d9 d10 d11)
         (bitvector-put! writeport
             (decode-hamming-11/7 p1 p2 d3 p4 d5 d6 d7 p8 d9 d10 d11))))

Best wishes,
Arne
--
Unpolitisch sein
heißt politisch sein
ohne es zu merken