Quirksand

SICP

SICP 2.3.1 Exercises

January 31, 2015 11:48

In this section we get into an extremely useful new form of expression, the quoted form. Having some form of this allows a wide variety of expressions to use. Rather than having only lists of numbers or already-defined variables, we can use quoted lists. But the more valuable effect is that we can have an expression that isn’t evaluated by the Scheme interpreter right away (or ever). This will be critical when we get to actually defining and interpreting expressions and even whole languages of our own.

The text has a footnote claiming that allowing quotation causes the problem that we can’t have an easy comparison of ‘equal values’, but that’s really just another indication that we mustn’t confuse use and mention, to borrow the linguistic terms. Anything that is literal is not the same as the thing referred to by that expression. The idea of having expressions that merely refer to something gets at the heart of what an interpreter does — it takes as input literal expressions ‘literal’ is also an alternate name for quoted symbols and converts them to what the language says that expression means.

Philosophical digressions aside, these exercises are pretty short, and easily verified. Aside from the ones that can be solved by simply running them through the interpreter, there are pass/fail tests to determine if the function works as we expect. Other checks simply give true/false results, since those do not have a particular expected result, and are there for experimentation.

Exercises 2.3.1