0

After playing with vectors and complex numbers in Common Lisp, I became curious about something. Namely, how does the quote operator relate to these data structures?

For instance, when it comes to lists, the following examples are straightforward to me:

CL-USER> '(1 2)
(1 2)
CL-USER> ''(1 2)
'(1 2)

Let's do the same with vectors:

CL-USER> #(1 2)
#(1 2)
CL-USER> '#(1 2)
#(1 2)
CL-USER> ''#(1 2)
'#(1 2)

And complex numbers:

CL-USER> #c (1 2)
#C(1 2)
CL-USER> '#c (1 2)
#C(1 2)
CL-USER> ''#c (1 2)
'#C(1 2)

To save space, I will just say that quoting characters behaves similarly.

My question is why is it that the # and '# evaluated to the same expression? What is the reason for that? What are the "guts" of this mechanism?

MadPhysicist
  • 5,401
  • 11
  • 42
  • 107
  • 3
    Most things in Common Lisp (numbers, vectors, strings, CLOS objects, ...) are just evaluating to themselves. Symbols and Lists don't - you need to quote them for that. Exceptions: keyword symbols. – Rainer Joswig Oct 27 '17 at 16:18
  • This is not a duplicate. First of all, I already know when to use quote. Second of all, the question you mention makes no mention of vectors, complex numbers and characters. The question I am asking is why the quote and no quote evaluate to the same expression for vectors, complex numbers, etc. – MadPhysicist Oct 27 '17 at 16:55
  • *why the quote and no quote evaluate to the same expression for vectors, complex numbers, etc.* -> to what should they evaluate else? – Rainer Joswig Oct 27 '17 at 21:04

0 Answers0