3 ms·
Remember when you learned how recursion works? This is a similar case. You'll learn how to understand how a Lisp interpreter works. You'll get an extremely sim
by lispm 3y ago
Remember when you learned how recursion works?
This is a similar case. You'll learn how to understand how a Lisp interpreter works. You'll get an extremely simple one, which is written in itself. The same primitive language which is interpreted is used to write the interpreter. That's basically the local maximum of simplicity. You'll reuse much of Lisp, including the data structures, I/O, memory management, etc. But you can concentrate on the core of the interpreter: how does it process lists of code to compute a result. Thus you'll see a minimal language applied to itself. The minimal language can be written in very primitive list processing operations in a few lines of code.
I've taken one of McCarthy's example interpreters and made the language Common Lisp compatible. One can then load the interpreter into Common Lisp and run example programs. Which example programs could we run? We can run the interpreter itself. Then we have an interpreter of the small Lisp, which runs itself and which itself is running in a larger, but compatible, Lisp.
https://gist.github.com/lispm/d752d5761f7078de4041d4e453e70cbe https://gist.github.com/lispm/d752d5761f7078de4041d4e453e70c...
When you run this Lisp in Lisp, you can debug itself, while it is running in itself... which you can then debug, too.
Once you understand how this simple interpreter works, you can then start thinking of changing it: tweaking the implemented language, making it faster, implement a larger language, ...