My New Experimental Lisp

Warning: subject to frequent changes and breakages


This small version of lisp is experimental in a few ways. I'll go ahead and list all the defined variables, which are available at this prompt.

First, we've got the traditional lispy bits. atom, cons, car, cdr, eq, quote, and if (and if behaves in the typical short-circuiting way). For the most part, these behave as expected. Next, we have the arithmetical operations +, -, *, /, and % (modular arithmetic). All only work on integers at the moment. One of the most important builtins is def, which defines global variables. For example, (def x 5) stores the value 5 in the variable x.

There are only two more builtins, and they are by far the most important pieces. The first is lambda, which is maybe a bit more simplified than what you might be used to, but is nonetheless similar. (lambda x x) is the identity function, ((lambda x (+ x 5)) 6) returns eleven, and so on. Nothing terribly surprising here. The other important builtin is called mlambda, and is one of the ways in which this lisp particularly stands out. It behaves like the lambda, but doesn't evaulate its argument. This really allows some powerful features.

To show this off, let's go ahead and define something handy. Most lisps have some sort of 'let' tool to make local bindings, and indeed we can build something like that with what we already have. Consider the following:

(def let (mlambda binding (mlambda form (cons (cons lambda (cons (car binding) (cons form Nil))) (cons (cdr binding) Nil)))))

This gives us a simple form that when given (let (var val) form) will bind val to var and evaluate form with that binding.