SICP Exercise 2.55
Question
Eva Lu Ator types to the interpreter the expression
(car ''abracadabra)
To her surprise, the interpreter prints back quote
. Explain.
Answer
It is useful to read the footnotes in SICP, which in this case contain the answer to the question. Footnote 100 gives us the following information:
Thus, we would type
(quote a)
instead of'a
, and we would type(quote (a b c))
instead of'(a b c)
. This is precisely how the interpreter works. The quotation mark is just a single-character abbreviation for wrapping the next complete expression withquote
to form(quote ⟨expression⟩)
. This is important because it maintains the principle that any expression seen by the interpreter can be manipulated as a data object.
So the quotation mark is actually translated by the interpreter to quote
,
which is a function name. Since this is itself being quoted i.e. its string
value returned, the return value is simply quote
.