[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#9469: buffer-local variables seem to remember previous values
From: |
Helmut Eller |
Subject: |
bug#9469: buffer-local variables seem to remember previous values |
Date: |
Sun, 11 Sep 2011 21:37:25 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
* Lars Magne Ingebrigtsen [2011-09-11 18:54] writes:
> Le Wang <l26wang@gmail.com> writes:
>
>>> This has nothing to do with the use of quote, but with the use of
>>> destructive functions (setcdr) on a shared data structure.
>>
>> Of course you're technically right, but should the manual mention in
>> the "quoting" section that using quote the way I did results in a
>> shared data structure? This part was surprising to me.
>
> If I read your code correctly, Andreas is correct and precise as usual,
> if a bit terse. :-)
>
> The thing you're seeing has absolutely nothing to do with the use of
> quote.
>
> You're destructively altering a single list and expecting to see the
> list be different in various buffers.
Well, quote is tricky! It wouldn't hurt to point out that modifying a
quoted list often means modifying your code. E.g.
(defun foo ()
(let ((list '(1 2 3)))
(setcdr list (cddr list))))
(equal (copy-tree (symbol-function 'foo))
(progn
(foo)
(symbol-function 'foo)))
returns nil. I think few beginners will see that using setcdr here not
only modifies the value stored in the variable list but also modifies
the s-exp stored in 'foo.
Helmut
- bug#9469: buffer-local variables seem to remember previous values, (continued)
- bug#9469: buffer-local variables seem to remember previous values, Stefan Monnier, 2011/09/13
- bug#9469: buffer-local variables seem to remember previous values, Le Wang, 2011/09/13
- bug#9469: buffer-local variables seem to remember previous values, Helmut Eller, 2011/09/13
- bug#9469: buffer-local variables seem to remember previous values, Johan Bockgård, 2011/09/13
- bug#9469: buffer-local variables seem to remember previous values, Drew Adams, 2011/09/13
- bug#9469: buffer-local variables seem to remember previous values, Helmut Eller, 2011/09/13
- bug#9469: buffer-local variables seem to remember previous values, Le Wang, 2011/09/15
- bug#9469: buffer-local variables seem to remember previous values,
Helmut Eller <=
- bug#9469: buffer-local variables seem to remember previous values, Andreas Schwab, 2011/09/11