Scheming, part 1
Posted by kernelbob on September 25, 2008
I have a Scheme interpreter.
~/scheme> ./scheme > () > 123 123 > + #<C-proc 0x804ad19> > (+ 12 34) 46 > (lambda (x) x) #<proc 0x80590f8> > ((lambda (x) (+ x x)) 3) 6 > [Ctrl-D] ~/scheme>
There’s less here than meets the eye. The interpreter has exactly three built-in procedures: +, – and lambda. The only numbers are fixnums (fixed-size integers). There is no garbage collection – it calls malloc() but doesn’t call free(). The reader doesn’t recognize quotes, dotted pairs, or comments. There are no vectors, hashes, byte arrays, etc. No exceptions, call/cc, threads, etc. No tail recursion.
I wrote it in C, as promised.
Once upon a time, I wrote an emacs clone. It was the style back then to name emacs clones with recursive acronyms. We had MINCE (MINCE Is Not Complete Emacs), EINE (Eine Is Not Emacs) and ZWEI (Zwei Would Emacs Emulate). Mine was MINE, which stood for “MINE Is Not Emacs, but it’s mine”.
This scheme interpreter is nothing special, but it’s mine.