On Mon, 28 Oct 2002, Josh Huber wrote:
Given this defun:
(defun jmh-test-func ()
(setq tv '((?a) (?b)))
(push "testme" (cdr (assoc ?a tv)))
Why does the value returned keep accumulating data from previous
It's driving me crazy! I was under the impression let created a
binding which was destroyed when the let statement went out of scope?
Sure, the value of 'tv' is restored, but the constant list you are
setting it to isn't protected by the let at all...
Clearly, I must be missing something... :)
I would suggest that Emacs is reusing the same constant list each time
this is called, so that your `push' modifies that.
When I re-eval the defun, xemacs "forgets" the old values,
insanity starts all over!
This would be consistent, since evaluating the definition again would
create a new constant list, replacing the previous one.
`let' protects the value you specify in it, not the values that are
referenced by protected values. So, in this case, `tv' will be restored
to the value it had outside the function but the content isn't.
Impropaganda: Using propaganda techniques not in accordance with good sense,
good faith, or good morals... methods not consistent with the American pattern
of behavior based on Judeo-Christian ethics.
-- Edward L. Bernays, author of Crystallizing Public Opinion (1923)