0

The following code gives unexpected behavior:

(defun my-make-list () '(5 5 5))

(setf my-list (my-make-list))

(setf (car my-list) 3)

(my-make-list)

====> (3 5 5)

I set up my-make-list to be a function which always returns the list (5 5 5). And yet when I use setf to assign the output of the function to my-list; and then use setf to change one of the items in my-list, it seems that the definition of the function changes. It's now a function which always returns the list (3 5 5).

What's going on?

coredump
  • 37,664
  • 5
  • 43
  • 77

0 Answers0