Scheme from Scratch - Bootstrap v0.16 - Let
We could have lived our lives without adding
cond. It is a convenience form and there are a few others that are handy to have around:
let is one of them.
Sample REPL session:
$ ./scheme Welcome to Bootstrap Scheme. Use ctrl-c to exit. > (let ((x (+ 1 1)) (y (- 5 2))) (+ x y)) 5
let form is also “library syntax” and so the implementation is another abstract syntax tree manipulation. This time it is a manipulation that converts the
let form to a procedure application with a
At this point you may be thinking these abstract syntax tree manipulations could become tedious to implement. Macros exist for this reason and so that the programmer can invent his own new library syntax. We only need a few bits of library syntax for a bootstrap interpreter and it is easier to implement directly in C than to implement macros in C and then the library syntax in Scheme.
There is a v0.16 branch on github for this version.
Have something to write? Comment on this article.