2011-11-03

SICP Exercise 2.55: Quoted Quotes

Eva Lu Ator types to the interpreter the expression
(car ''abracadabra)
To her surprise, the interpreter prints back quote. Explain.

As noted in footnote 34, the single quotation mark is equivalent to the special form quote... and in fact the single quotation mark is simply an abbreviation for quote. So the interpreter will process Eva's expression as if it were:
(car (quote (quote abracadabra)))
The outer quote quotes the inner expression, and so produces the list:
'(quote abracadabra)
car then returns the first element from this - i.e. quote.

No comments:

Post a Comment