"Lennart Borgman (gmail)" <lennart.borgman@gmail.com> writes:
spamfilteraccount@gmail.com wrote:
Here are two functions:
(defun testfun1 ()
(interactive)
(setq a '(0 0))
(print a))
(defun testfun2 ()
(interactive)
(incf (car a))
(print a))
I call the first one, a is (0 0).
I call the second one, a is (1 0).
I call the second one, a is (2 0).
I call the first one, a is (2 0).
"a" won't get the value (0 0) again until I redefine testfun1.
I suspect it is caused be some kind of internal optimization. Is it
intentional? It cost me a great deal of head scratching to find out
why my program doesn't work.
Are you using Emacs 22? Could you then please file a bug report?
There is no bug, and no optimization involved. This is expected and
correct behavior (anything else would be _wrong_). A quoted list is
not regenerated when a function is entered new. A quoted list is
evaluated to a cons cell at _compile_ time. The contents of this cons
cell can be changed with setcar (or, in this case, incf).