Exercise 1.4.20
More Quoting
Because quote
supresses evaluation, you can use it to more easily build deeply nested structures.
* (list 1 (list 2 3) (list 4 (list (list 5) 6 7 8)))
(1 (2 3) (4 ((5) 6 7 8)))
* '(1 (2 3) (4 ((5) 6 7 8)))
(1 (2 3) (4 ((5) 6 7 8)))
Take care not to use quoted data for mutation though. While the structures produced may be the same, mutating a quoted structure is undefined by the Common Lisp language spec, and is thus entirely implementation dependant.
* (defvar *listed* (list 3 2 1))
*listed*
* (defvar *quoted* '(3 2 1))
*quoted*
* (push 4 *listed*)
(4 3 2 1)
* *listed*
(4 3 2 1)
* (push 4 *quoted*)
???
* *quoted*
???
The question marks aren't there so you can figure out what the results are supposed to be. They signify that what you get back in these situations depends on which implementation of Common Lisp you're using. They may do incompatible things, but because the spec leaves this situation undefined, none of them are actually wrong. So, you know ... careful.