Software Defined Automatic Calculator

This article is about SDAC. It is a program that takes in a LISP-like language, and prints out a sequence of evaluated statements. Here we compute the answer to everything:

(exp mul (val . 21) (exp add (val . 3) (val . -1)))

This looks very simple and it is; even cooler, the implementation is as simple.

Implementation

At the basis of SDAC there is the Program type. A “Program” can be either be a value (signed word), or an expression. Then there are two functions, the detection function, and the evalutation function. The detection function matches the type of the program; if the program is a value we return that value, if it is an expression we evaluate that expression. The evalutation function matches and executes the expression, returning a value.

Doing this in a recursive fashion opens up the possibility to write real programs by compositing expressions.

LISP: The soul of a new machine

To be true to myself, I know some LISP, but I never learned it formally from first principles. So that is what I will be doing. And who knows, maybe I will write an article about my experience learning LISP (This is unapologetic foreshadowing).

Sources