It seems that Common Lisp does treat (list 'quote 'x) in a special way. For example, the value of (list 'oddp '5) is '(oddp 5) while the value of (list 'quote '5) is ''5. In other words, the quote function seems to be evaluated even though it should be in data mode due to the quote in front of it.
Compare the value of the following expressions:
1. (list 'quote '5) = (list 'quote 5) = (quote '5) = ''5
2. (list '' '5) = '(''5)
3. (list ' 5) = (list 5) = '(5)
4. (list 'oddp '5) != (oddp 5)
The evaluation appears to be very idiosyncratic. But I reckon that I might be very confused.
Can someone help me to better understand the pattern here?
What does = mean? You might use it for two different things: equality after read and equality after evaluation. Btw., in Lisp itself the function
=compares numbers.The first step is reading:
(list 'quote '5)read >(LIST (QUOTE QUOTE) (QUOTE 5))(list '' '5)read >(LIST (QUOTE (QUOTE (QUOTE 5))))(list ' 5)read >(LIST (QUOTE 5))(list 'oddp '5)read >(LIST (QUOTE ODDP) (QUOTE 5))Now
'is a read macro. It transforms the next textual form.'someformis just read as(QUOTE SOMEFORM). The printer may retransform this when printing it. Note how it interacts with pretty printing. The following example is in LispWorks:Note also that the quote readmacro character
'reads over whitespace.'5is read the same as for example' 5.But it is good style to put the quote directly in front of the next expression, without whitespace.
The second step is evaluation:
(LIST (QUOTE QUOTE) (QUOTE 5))eval >(QUOTE 5)prettyprint >'5(LIST (QUOTE (QUOTE (QUOTE 5))))eval >((QUOTE (QUOTE 5)))prettyprint >(''5)(LIST (QUOTE 5))eval >(5)(LIST (QUOTE ODDP) (QUOTE 5))eval >(ODDP 5)