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

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

bug#9261: `let' behavior is strange


From: Andreas Schwab
Subject: bug#9261: `let' behavior is strange
Date: Mon, 08 Aug 2011 19:15:53 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)

小江沈 <xiaojiang@siteshen.com> writes:

> (progn (put 'defun 'x "out")
>        (let ((old (plist-member (symbol-plist 'defun) 'x)))
>          (message "old: %s." old)
>          (put 'defun 'x "in")
>          (message "old: %s." old)
>          nil))
>
> When I eval this form, I get something like this in *message* buffer:
> old: (x out).
> old: (x in).
> nil

This has nothing to do with let.  plist-member returns a tail of the
property list, and when the value of an existing property is changed
only the cdr of the cons cell is overwritten by put, so the reference to
the cons cell in `old' will follow the change.

> If it is not a bug, how can I save the prev symbol property?

Use plist-get or get to extract the property value, or make a copy.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."





reply via email to

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