A Portable SRFI-4 Implementation

by John Cowan

The portable SRFI-4 implementation in this directory is constructed in two layers. It should work on any R6RS or R7RS system, or any Scheme that provides even minimal bytevectors: it relies only on the primitives make-bytevector, bytevector?, bytevector-length, bytevector-u8-ref, and bytevector-u8-set!. The implementation also uses either SRFI 9, R6RS record types, or R7RS record types. However, it should not be used to replace a native SRFI 4 implementation, as it is very likely to be much less efficient.

The lexical syntax of SRFI 4 is not provided.

Note that on R6RS systems the library is named (srfi :4), whereas on R7RS systems it is named (srfi 4).

Bytevector library layer

The lower layer is a portable implementation of the R6RS bytevector library. So that it can be run and tested on R6RS systems, it is named (r6rs bytevectors) rather than (rnrs bytevectors (6)). It depends only on the five primitives. (In Chicken 5 these are simulated with u8vectors from the native SRFI 4 implementation.)

However, if a native R6RS library is available, it is likely to be much more performant and should be used instead. In particular, the conversions between bytes and strings, and between bytes and inexact numbers, can be implemented much more efficiently in a low-level language such as C.

The following files are provided for this layer:

SRFI-4 layer

The upper layer provides the procedures of SRFI 4. It can be layered over either the (r6rs bytevectors) library or a native (rnrs bytevectors (6) library.

The following files are provided for this layer:

Running tests

All tests must be run from the directory containing this README file. The shell script all-tests will run all tests. It assumes that the Chicken 5 compiler and interpreter are on the shell's search path as csc and csi, the Chibi interpreter as chibi-scheme, the Guile 2.x interpreter as guile and the Ypsilon interpreter as ypsilon. All lines ending in OK represent successful tests and are filtered out by default. Simply comment out runs of any Schemes you don't have.