Comment by nils-m-holm
5 years ago
Here is a minimal LISP compiler in 400 lines of LISP that does not gloss over anything:
http://t3x.org/lfn/liscmp.lisp.html
It only depends on about 350 lines of LISP code for standard functions like CADR, APPEND, READ, etc, plus avout 400 lines of C for low-level stuff (variable binding and garbage collection).
The 350 lines of LISP standard function even contain low-level things like interning of symbols:
http://t3x.org/lfn/lisp.lisp.html
Even the garbage collector could be written in LISP
http://t3x.org/lfn/gc.lisp.html
but there are a few issues that are not addressed in the code. For a full explanation of the compiler and some bits of historical trivia, see
This is very interesting, thank you! At first glance, it does perhaps gloss over a few things still: instruction encoding, jump-target backpatching (or its moral equivalent), the system call interface, the fetch-execute cycle, and a debugger; but not, for example, function entry and exit, or, as you point out, garbage collection or the reader. Also, on p. 16, there's an error seemingly due to the author not knowing about the Y-combinator:
The author is the commenter :)
Oh, so he is. I wonder if he'll explain I misunderstood him or correct the error.
5 replies →