scm1

scm1 is a toy interpreter based on a subset of scheme I wrote one weekend. It is built for educational purposes and is my first experience in implementing a lisp.

The code is extremely terse and so it follows that the syntax of scm1 is as well. The inspiration comes from Arthur Whitney and some of his ideas on PL design, most notably his Array-based lang k. Instead of def! or define we have the : function, instead of an if conditional we have ?, and the lambda function is f.

  λ ; define a function 'x' which takes an argument and adds 2 if it's less than 10, else print 'nope'
  λ (: x (f (a) (? (< a 10) (+ a 2) (m "nope")))))
  x
  λ (x -1)
  1
  λ (x 9)
  11
  λ (x 10)
  nope
...
  λ ; factorial  
  λ (: fak (f (n) (? (< n 2) 1 (* n (fak (- n 1))))))
  λ (fak 10)
  3628800  

Overall, I'm happy with the choices I've made in this small language - I got the chance to see how it feels to write terse Rust, learned about lisp implementations, and got a nice little demo program out of it.

In retrospective, there are a few things worth commenting on: