Scheme from Scratch - Bootstrap v0.15 - Cond
The only remaining part of the first meta-circular interpreter of SICP still to port to our interpreter is the
Sample REPL session:
$ ./scheme Welcome to Bootstrap Scheme. Use ctrl-c to exit. > (cond (#f 1) ((eq? 'a 'a) 2) (else 3)) 2
cond form is “library syntax” and so the implementation of
cond is an abstract syntax tree manipulation to convert the form to a series of nested
if forms. The conversion algorithm is spelled out for us in SICP.
SICP notes and discusses how inefficient the implementation is. Every time a single
cond form is evaluated it is (re)converted to nested
if forms. This is inefficient and the second meta-circular interpreter addresses this issue; however, for the purpose of a bootstrap intereter, simple is more important than efficient.
We’ve reached an important milestone along our path. The port from SICP is complete. Any extra functionality we need for our interpreter to be a useful bootstrap interpreter we will need to figure out how to implement on our own.
There is a v0.15 branch on github for this version.
Have something to write? Comment on this article.