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: David Kastrup
Subject: Re: Strange incf behavior in Emacs 22. Intentional?
Date: Fri, 29 Jun 2007 00:32:28 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux)

"Lennart Borgman (gmail)" <address@hidden> writes:

> address@hidden 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).

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum


reply via email to

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