Lisp in Lisp
The simplest meta-circular interpreter for Common Lisp:
> (loop (print (eval (read))))
(+ 2 3)
=> 5
(defun sqr (x) (* x x))
=> SQR
(sqr 10)
=> 100
[abort]
; Evaluation aborted
>
To write the same in Scheme, we should first define the loop form.
> (define-syntax loop
(syntax-rules ()
((_ body ...)
(let _loop ()
body ...
(_loop)))))
> (loop (print (eval (read))))
(+ 2 3)
=> 5
(define (sqr x) (* x x))
=> <void>
(sqr 10)
=> 100
[abort]
; Evaluation aborted
>