Scoban would be an interpreter. I.e., we want it to be able to read strings with Scoban expressions in them and something with them.
Your average lisp comprises such atomic data types (and so that’s what we want Scoban to have):
type | description | example |
---|---|---|
boolean | true or false value | #t , #f |
integer | self-evaluating number | 1 , -65536 |
symbol | immutable sequence of C chars | car , #t , ¡Жопа! |
string | mutable sequence of C chars | "Это интересно" |
list | ?? |
Out of them with a bit of magic we can produce compound data types:
type | description | example |
---|---|---|
cell | set of two values, car and cdr | (a . b) |
nil | set with cdr pointing to NULL | () |
list | chain of cells | (1 2 3) , (cond 1 (cond 2 (cond 3 ()))) |
string | a mutable and self-evaluating symbol | String are vowen by spiders. |
First of all, we need to build a parser of Scoban expressions. It would take an arbitraty – possibly valid – expression, and return a thing we would be able to execute.
We also need a read
function that would recursively convert an expression into atomic datum
in some order.
To get a working eval
, we must introduce some building blocks.
According to St. Graham, there are seven essential primitives:
car
cdr
cons
cond
quote
atom
eq
We also need a way to define things and a `lambda`, so we could define functions and thusly define
(eval)
, (apply)
, (bind)
etc.
We would need these:
So we would get this: https://upload.wikimedia.org/wikipedia/commons/0/0e/Jerry_Sussman.jpg
That’s all there is to an interpreter.