back to notes

Sean Burke LISP madness

I'm wading through some early-1960s #Lisp code by some people of just break-out levels of evil/eval superscience brilliance.

My favorite bit is this one program... it's about 5 pages, and it defines about 30 functions which are just kookoo...

Here's my favorite part of it so far, starting with the part that defines a (relatively) top-level function:

DEFINE((

...

(TRANSLATE (LAMBDA (X) (COND ((NULL X) NIL) ((ATOM (CAR X)) NIL) ((EQ (CAAR X) 'DEFINE) (APPEND (DEF (CAR X)) (TRANSLATE (CDR X)))) (T (APPEND (PROPFORM (VERB (CAR X))) (TRANSLATE (CDR X)))) )))

(DEF (LAMBDA (X) (LIST 'DEFINE (LIST (LIST (LIST (CADR X) (LIST 'LAMBDA (UNWIND X) (DEFN (LAST X)))))))))

(UNWIND (LAMBDA (X) (VAR X (FIFTH X)))))

(FIFTH (LAMBDA (X) (CAR (CDDDDR X))))

(DEFN (LAMBDA (X) (COND ((NULL X) NIL) ((EQUAL (CAR X) 'IF) (CONS 'COND (DEFM X))) (T (VERB (CONS (CAR X) (DEFN (CDR X))))) ) ))

(PROPFORM (LAMBDA (X) (COND ((EQUAL (LENGTH X) L) X) (T (CONS (CAR X) (LIST (CDR X)))) ) ))

...))

Yup! this defines λs that call λs that call themselves to construct λs that call themselves, using some utility λs to produce and evaluate code for λs that calls those utility λs,...
Your eyes do not deceive you— DEFINE is defining a function DEF, which, of course, produces code for a function that calls the function DEFINE.

There's about seven "DEF[letter]" functions in the source. This code refers to one, DEFM, which is missing in this source code (along with the misterious "L" in the last function) because.. did I mention?... there's a part of a page missing from the code listing.

This is a hoot!

And of course, this Lisp predates such modern constructs as: 'foo or '(bar baz) or (x . y) or (defun...) or (defmacro...) or even some of that `,@',(,`@`` stuff that's the worst thing in the world except for everything else.

Later, the code redefines "IF" itself... recursively... because, you know,... some things need doing. (More on that later.)


last updated november 2019