Skip to content

Latest commit

 

History

History
60 lines (44 loc) · 2.33 KB

IMPLEMENTATION.org

File metadata and controls

60 lines (44 loc) · 2.33 KB

Scoban implementation guide

Going up

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.

Data types

Your average lisp comprises such atomic data types (and so that’s what we want Scoban to have):

typedescriptionexample
booleantrue or false value#t, #f
integerself-evaluating number1, -65536
symbolimmutable sequence of C charscar, #t, ¡Жопа!
stringmutable sequence of C chars"Это интересно"
list??

Out of them with a bit of magic we can produce compound data types:

typedescriptionexample
cellset of two values, car and cdr(a . b)
nilset with cdr pointing to NULL()
listchain of cells(1 2 3), (cond 1 (cond 2 (cond 3 ())))
stringa mutable and self-evaluating symbolString are vowen by spiders.

Parser and read

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.

Primitives

To get a working eval, we must introduce some building blocks. According to St. Graham, there are seven essential primitives:

  1. car
  2. cdr
  3. cons
  4. cond
  5. quote
  6. atom
  7. eq

We also need a way to define things and a `lambda`, so we could define functions and thusly define (eval), (apply), (bind) etc.

Building an interpreter

We would need these:

  1. https://upload.wikimedia.org/wikipedia/commons/7/78/Fes.jpg
  2. A dark brown felt jacket

So we would get this: https://upload.wikimedia.org/wikipedia/commons/0/0e/Jerry_Sussman.jpg

That’s all there is to an interpreter.