I'm teaching myself some more elisp and have encountered the following problem:
If I want to reset a list variable it won't get updated after the first evaluation. Here is some example code:
(defun initilize () (setq example '(3))) (defun modify () (initilize) (message "%S" example) (setcar example 2)) ; M-x eval-buffer RET (modify) ; message --> (3) (modify) ; message --> (2) (modify) ; message --> (2)
I'm interested in two things. The first is to learn more about what is happening "under the hood" so why does it work the first time and fails on subsequent calls?
The second and more practical question is how to reinitialize the list properly or is there another common way of doing something like that?
One workaround I found myself is to use a quoted list and evaluating the content like this:
(setq example `(,3))