In Lisp, expressions are always evaluated, meaning a variable or function can’t be referenced without quoting.
For example, evaluating rhubarb
in Emacs Lisp produces an error, because a variable named rhubarb is not defined:
rhubarb
eval: Symbol’s value as variable is void: rhubarb
To reference a variable or a function, it needs to be quoted:
(quote rhubarb)
rhubarb
A shorthand for quoting a variable is placing a single quote in front of it. The following is equivalent to the previous example:
'rhubarb
rhubarb
Quoting twice produces a list, because the first call to quote
turns the rest of the expression into a two-element list.
(quote (quote rhubarb))
'rhubarb
The string representation of the return value is 'rhubarb
, which is confusing but correct following the conventions of printing values.
A quoted variable is printed as rhubarb
(or RHUBARB
in Common Lisp), so a double-quoted variable should be 'rhubarb
.
This means the car
of the list is the symbol quote:
(eq 'quote (car (quote (quote rhubarb))))
t