LYSP — 50 Years of Symbolic Processing

Last weekend I was thinking about Ashwin Ram's Short Ballad Dedicated to the Growth of Programs and the result is LYSP: a tiny, lightweight Lisp interpreter closely following the tradition of the earliest implementations. It is dedicated to the inventor and early implementations of that language, which is 50 years old this year. If you partially evaluate LYSP in Latin it yields "50 Years of Symbolic Processing".

(IBM once made a dialect of Lisp called Lysp and published a paper about it. As far as I know, it died shortly thereafter and so I have unilaterally swept and reallocated the name. If you know differently, please tell me.)

Being a weekend hack there are probably numerous bugs (not to mention the unspeakable things it does with __builtin_apply that are courting portability disaster). If you find one, send a description (or perferably a prescription) to the author: Ian at the domain name of this site. If you find you can't break it and manage to use it for something interesting, I'd love to hear about it.

It started off really small (about 150 LOC) but I got carried away. I hope you will forgive the bloat. Compiled on x86 with gcc -Os it's about 17 KB for the interpreter and 4 KB the garbage collector (a cheesy, home-made, stop-world, precise collector -- although it can also use the classy, incremental, conservative Boehm-Demers-Weiser one in /usr/lib). That makes for about 21 KB of self-contained Lisp interpreter, including a rudimentary (but useful) FFI and macros, that runs at about 1 million funcalls per second on my Q9450. (If you do something interesting with it in the embedded space, I'd love to hear about that too.)

Download the source code: lysp-1.1.tar.gz
Browse the source code: lysp-1.1
Read the manual page: when I get round to it
If you unpack it and type make it will try to build two versions of the interpreter, one with the built-in collector and one with the Boehm collector. Obviously, you should acquire (and build if necessary) and install that first. (On Ubuntu you can type
sudo apt-get install libgc-dev
to fetch and install it.) If you want to avoid that hassle, type make lysp to build just the version with the cheesy, home-made garbage collector.

LYSP is distributed under the MIT license. It will not infect you with a contagious disease if you decide to use all or part of it for your own purposes.

And yes: '(cdr (assq key a-list))' does exactly what you want it to in LYSP.

2012-01-12 version 1.1
Added missing definition of rplacaSubr to lysp.c. (Thanks to Jim Knight for spotting this.)