Micro Common Lisp

4 hours ago 2

Download (v.03, 80KB)  |  Manual  |  T3X source code  |  LISP source code

MICRO COMMON LISP is a tiny interpreter for a tiny and purely symbolic subset of Common LISP. It consists of 1570 lines of T3X (alternatively C) and LISP code and runs in less than 64K bytes of memory, even on CP/M. Despite its small size it offers:

  • lexical scoping
  • separate namespaces
  • tail call optimization
  • macros
  • quasiquotation
  • variable-argument functions
  • constant-space garbage collection
  • image files
  • line editing and history
  • >5000 free cons cells on DOS

The interpreter core implements nine special forms and 20 functions, and the rest of the system is bootstrapped in LISP. To compile the core, a T3X/0 or C89 compiler is required. A DOS COM file (23KB) is included in the archive.

Both the core and the LISP part of the system are thoroughly documented. Although the system is small, its implementation is carefully designed. It is not just another half-baked "I just wrote a LISP for lolz" implementation. Check it out, you might draw some inspiration from it! The code is in the public domain (or under the 0BSD licence, if you prefer that).

What can you do with such a limited systems? There are not even integers, just lists, symbols, and functions. For example, the source code archive contains a LISP pretty-printer (GRIND), a tiny PROLOG interpreter, a basic LISP interpreter, and a natural number math library based on lists.

Sample Sessions

Here you can have a look at MICRO COMMON LISP in action:

Pretty-Printing and Macro Expansion The Natural Number Math Library A Tiny PROLOG Interpreter

Then there is my essay about LISPy things you can do in 64K bytes of core, which covers much of the above, but is about a different dialect of LISP.


Read Entire Article