Skip to content

eliassona/mylisp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mylisp

Lisp interpreter. Ever since I got into Lisp and more specifically Clojure I've been fascinated by the Lisp eval/apply functions. How can something so small be so powerful? Naturally I had to implement a Lisp interpreter myself. This way I'll hopefully understand why it's so powerful.

I especially like the macro part. It's just an extra condition of apply. By adding this condition you get a macro system!!

The first 130 lines contains the interpreter. The following lines uses the interpreter to build an environment for the interpreter. Adding standard functions and macros such as reduce etc.

The code of the interpreter here [https://github.com/eliassona/mylisp/blob/master/src/mylisp/eval.clj]

I implemented this interpreter only because I wanted to understand the eval/apply of Lisp not because it is useable in any way (it is not).

Below are some examples.

The main function of the interpreter is called evl

(use 'mylisp.eval)
(evl (+ 1 1))
2

Define a value

(evl (def a 1))
nil
(evl a)
1

Define a function

(evl (def a-fn (fn [x] (+ x 1)))) 
nil

Call the function

(evl (a-fn 1))
2

let is implemented as a macro using lambda

(evl 
  (let [a 1
        b 2]
 (+ a b)))
3 

About

My Lisp Language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors