A Common Lisp library for accessing octet-addressed blocks of data
Common Lisp
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
doc release v0.11 Jan 15, 2013
sbcl-opt Fixed defknown errors using the :overwrite-fndb-silently keyword para… Mar 7, 2017
.gitignore add .gitignore Mar 18, 2010
.travis.yml use only CL-interned symbols in .travis.yml May 23, 2015
LICENSE add LICENSE file; better late than never Mar 18, 2010
NEWS release version 0.13 Mar 7, 2017
README add README file Mar 18, 2010
nibbles.asd release version 0.13 Mar 7, 2017
package.lisp add stream functions for floats Nov 3, 2012
rt.lisp update rt.lisp Mar 20, 2012
tests.lisp Fix type declaration. Mar 15, 2015
types.lisp Exposed octet-vector types; added constructors Apr 19, 2012
vectors.lisp Fix typo in Allegro IEEE-DOUBLE-SETs. (#23) Nov 22, 2016


When dealing with network protocols and file formats, it's common to
have to read or write 16-, 32-, or 64-bit datatypes in signed or
unsigned flavors.  Common Lisp sort of supports this by specifying
:ELEMENT-TYPE for streams, but that facility is underspecified and
there's nothing similar for read/write from octet vectors.  What most
people wind up doing is rolling their own small facility for their
particular needs and calling it a day.

This library attempts to be comprehensive and centralize such
facilities.  Functions to read 16-, 32-, and 64-bit quantities from
octet vectors in signed or unsigned flavors are provided; these
functions are also SETFable.  Since it's sometimes desirable to
read/write directly from streams, functions for doing so are also
provided.  On some implementations, reading/writing IEEE singles/doubles
(i.e. SINGLE-FLOAT and DOUBLE-FLOAT) will also be supported.

In addition to centralizing such facilities, NIBBLES also aspires to
become a place where compiler optimizations can be written once and used
everywhere.  The intention is that (eventually):

  (nibbles:sb32ref/le vector index)

will compile (with any necessary safety checks) to a MOVSX instruction
on an x86oid processor in SBCL (or other implementations) if VECTOR and
INDEX are of appropriate types.

I remember reading a post on comp.lang.lisp that suggested the designers
of Common Lisp ignored the realities of octets and endianness and so
forth.  This library is a small step towards remedying that deficiency.