[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#12314: 24.2.50; `add-to-history': use `setq' with `delete'
From: |
Wolfgang Jenkner |
Subject: |
bug#12314: 24.2.50; `add-to-history': use `setq' with `delete' |
Date: |
Mon, 10 Sep 2012 13:54:40 +0200 |
User-agent: |
Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.2.50 (berkeley-unix) |
On Sun, Sep 09 2012, Drew Adams wrote:
>> Variables that point to that list structure will point to something
>> whose value is unpredictable, a.k.a. "garbage". It is enough to say
>> that the old value is garbage and shouldn't be used, IMO.
>
> No. It all depends. Lisp programs that use list modification do so sometimes
> for performance in calculating the new list, but more often they do so in
> order
> to take advantage of SHARING list structure.
>
> Consider the example I gave before:
>
> (setq a '(1 2 3 4))
> (setq b (cddr a))
>
> a => (1 2 3 4)
> b => (3 4)
>
> (delq 4 b)
>
> a => (1 2 3)
> b => (3)
Though using `delete' and friends this way would have unpredictable
results in ANSI Common Lisp[1] or Scheme (delete! in srfi1[2]), hence
may be regarded as questionable programming style in Emacs Lisp as well,
which I understand is Eli's point.
The following should work in both CL (except for the missing DEFVARs)
and Emacs Lisp, but sort of defeats the point about easy sharing ;-)
(setq a (list 1 2 3 4))
(setq b (cddr a))
(setf (cddr a) (setq b (delete 4 b)))
[1] http://www.lispworks.com/documentation/HyperSpec/Body/f_rm_rm.htm#delete
http://www.lispworks.com/documentation/HyperSpec/Issues/iss293_w.htm
[2] http://srfi.schemers.org/srfi-1/srfi-1.html#LinearUpdateProcedures
Wolfgang
- bug#12314: 24.2.50; `add-to-history': use `setq' with `delete', (continued)
- bug#12314: 24.2.50; `add-to-history': use `setq' with `delete', Drew Adams, 2012/09/08
- bug#12314: 24.2.50; `add-to-history': use `setq' with `delete', Drew Adams, 2012/09/08
- bug#12314: 24.2.50; `add-to-history': use `setq' with `delete', Eli Zaretskii, 2012/09/08
- bug#12314: 24.2.50; `add-to-history': use `setq' with `delete', Drew Adams, 2012/09/08
- bug#12314: 24.2.50; `add-to-history': use `setq' with `delete', Eli Zaretskii, 2012/09/08
- bug#12314: 24.2.50; `add-to-history': use `setq' with `delete', Drew Adams, 2012/09/08
- bug#12314: 24.2.50; `add-to-history': use `setq' with `delete', Eli Zaretskii, 2012/09/08
- bug#12314: 24.2.50; `add-to-history': use `setq' with `delete', Drew Adams, 2012/09/09
- bug#12314: 24.2.50; `add-to-history': use `setq' with `delete', Chong Yidong, 2012/09/09
- bug#12314: 24.2.50; `add-to-history': use `setq' with `delete', Eli Zaretskii, 2012/09/09
- bug#12314: 24.2.50; `add-to-history': use `setq' with `delete',
Wolfgang Jenkner <=
- bug#12314: 24.2.50; `add-to-history': use `setq' with `delete', Stefan Monnier, 2012/09/08
- bug#12314: 24.2.50; `add-to-history': use `setq' with `delete', Eli Zaretskii, 2012/09/08
- bug#12314: 24.2.50; `add-to-history': use `setq' with `delete', Stefan Monnier, 2012/09/09
- bug#12314: 24.2.50; `add-to-history': use `setq' with `delete', Eli Zaretskii, 2012/09/09
- bug#12314: 24.2.50; `add-to-history': use `setq' with `delete', Drew Adams, 2012/09/09
- bug#12314: 24.2.50; `add-to-history': use `setq' with `delete', Eli Zaretskii, 2012/09/09
- bug#12314: 24.2.50; `add-to-history': use `setq' with `delete', Drew Adams, 2012/09/09
- bug#12314: 24.2.50; `add-to-history': use `setq' with `delete', Stefan Monnier, 2012/09/09
- bug#12314: 24.2.50; `add-to-history': use `setq' with `delete', Eli Zaretskii, 2012/09/10
- bug#12314: 24.2.50; `add-to-history': use `setq' with `delete', Stefan Monnier, 2012/09/10