Subject: bug#9261: `let' behavior is strange

From: Andreas Schwab <[email-masked]>
Date: Mon, 08 Aug 2011 19:15:53 +0200

小江沈 <[email-masked]> 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, [email-masked]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."