Some output from the CLISP REPL:
[1]> (list 'list 1 2 3)
(LIST 1 2 3)
[2]> (list 'list '(1 2 3))
(LIST (1 2 3))
[3]> (list 'quote 1 2 3)
(QUOTE 1 2 3)
[4]> (list 'quote '(1 2 3))
'(1 2 3)
The first three, I understand exactly what's going on: The list
function is passed a symbol ('list
or 'quote
) and so the result is a list that begins with the list
or quote
symbol. It's the fourth that confuses me. Why doesn't it return (QUOTE (1 2 3))
?
I realise that if you enter (QUOTE '(1 2 3))
into the REPL, you get '(1 2 3)
back, so the expression are equivalent in that sense. But (LIST 1 2 3)
is equivalent to (1 2 3)
, and yet the first expression doesn't return that.
It seems inconsitent that (list 'quote 1 2 3)
returns a list with the first item being a quote
symbol, but (list 'quote (1 2 3))
returns a quoted list. Especially since expressions like (list 'list ...)
seem to always return a list beginning with the symbol - so far, at least, quote
is the only 'special case' like this.
It's not the easiest question to articulate, so I'm hoping I've managed to get my confusion across. Can anyone explain why quote gets treated in this seemingly-unique way?