File: README.md

package info (click to toggle)
acl2 8.6%2Bdfsg-2
  • links: PTS
  • area: main
  • in suites:
  • size: 1,111,420 kB
  • sloc: lisp: 17,818,294; java: 125,359; python: 28,122; javascript: 23,458; cpp: 18,851; ansic: 11,569; perl: 7,678; xml: 5,591; sh: 3,976; makefile: 3,833; ruby: 2,633; yacc: 1,126; ml: 763; awk: 295; csh: 233; lex: 197; php: 178; tcl: 49; asm: 23; haskell: 17
file content (34 lines) | stat: -rw-r--r-- 1,622 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Introduction #

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 `SETF`able.  Since it's sometimes desirable to
read/write directly from streams, functions for doing so are also
provided.  Reading/writing IEEE singles/doubles (i.e. `single-float`
and `double-float`) is also supported, with limitations on platforms
that do not fully implement IEEE floating point.

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):

``` common-lisp
(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.