help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange incf behavior in Emacs 22. Intentional?


From: Lennart Borgman (gmail)
Subject: Re: Strange incf behavior in Emacs 22. Intentional?
Date: Fri, 29 Jun 2007 01:29:52 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070604 Thunderbird/2.0.0.4 Mnenhy/0.7.5.666

David Kastrup wrote:
"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).


Ah, yes. I forgot about this case, but Juanma explained this before here.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]