Skip to content

Meta-circular evaluator for a very small Lisp embedded in CL

License

Notifications You must be signed in to change notification settings

inconvergent/cl-evl

Repository files navigation

EVL - Meta-circular Evaluator

(in-package :evl)

(let ((kv `((+ . +) (* . *) (1- . 1-) (t . t) (= . equal))))
  (labels ((env (x &aux (res (assoc x kv)))
             (if res (cdr res) (error "EVL: undefined variable: ~a" x))))

    (print (evl '(labels ((fact (x) (if (= x 0)
                                        1
                                        (* x (fact (1- x))))))
                   (fact 7))
                #'env))))

more examples in /ex.lisp.

Resources

For a great talk on this topic see this presentation by William Byrd:

The Most Beautiful Program Ever Written (https://www.youtube.com/watch?v=OyfBQmvr2Hc)