I'm reading An Introduction to Programming in Emacs Lisp by Robert J. Chassell.
When the book is introducing setcar, it points out that when we use this function to a list, the list should be initialized in this way:

(setq list1 (list 'a 'b 'c))

instead of

(setq list2 '(a b c))

And then

(setcar list1 'A)

But if I evaluate list1 and list2, Emacs gives me the same list (a b c).
I don't see any difference here. As a matter of fact, (setcar list2 'A) is also evaluated successfully.

Page 76
...Because we intend to use setcar to change the list, this setq should not use the quoted form '(antolope giraffe lion tiger), as that would yield a list that is part of the program and bad things could happen if we tried to change part of the program while running it.
Generally speaking an Emacs Lisp program's components should be constant (or unchanged) while the program is running. So we instead construct an animal list by using the list function, as follows: setq animals (list 'antelope 'giraffe 'lion 'tiger))


1 Answer 1


Internally, in function definitions, Emacs stores the list if it is written as '(a b c). If you modify it using destructing operations like setcar you actually change the function definition.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.