all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Wolfgang Jenkner <wjenkner@inode.at>
To: "Drew Adams" <drew.adams@oracle.com>
Cc: 12314@debbugs.gnu.org, cyd@gnu.org
Subject: bug#12314: 24.2.50; `add-to-history': use `setq' with `delete'
Date: Mon, 10 Sep 2012 13:54:40 +0200	[thread overview]
Message-ID: <85zk4yoyto.fsf@iznogoud.viz> (raw)
In-Reply-To: <7602D24B74DE42CF9901322634B85CA2@us.oracle.com>

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





  parent reply	other threads:[~2012-09-10 11:54 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-30 23:08 bug#12314: 24.2.50; `add-to-history': use `setq' with `delete' Drew Adams
2012-09-08 14:32 ` Chong Yidong
2012-09-08 14:43   ` Eli Zaretskii
2012-09-08 14:57     ` Drew Adams
2012-09-08 15:20       ` Eli Zaretskii
2012-09-08 15:48         ` Drew Adams
2012-09-08 16:05           ` Eli Zaretskii
2012-09-08 16:19             ` Andreas Schwab
2012-09-08 16:33               ` Eli Zaretskii
2012-09-08 16:50                 ` Lars Ingebrigtsen
2012-09-08 16:54                 ` Drew Adams
2012-09-08 17:06                 ` Andreas Schwab
2012-09-08 16:35               ` Drew Adams
2012-09-08 16:25             ` Drew Adams
2012-09-08 16:32               ` Eli Zaretskii
2012-09-08 16:42                 ` Drew Adams
2012-09-08 21:21                   ` Eli Zaretskii
2012-09-08 22:26                     ` Drew Adams
2012-09-09  3:00                       ` Eli Zaretskii
2012-09-09  6:29                         ` Drew Adams
2012-09-09  7:53                         ` Chong Yidong
2012-09-09 17:25                           ` Eli Zaretskii
2012-09-10 11:54                       ` Wolfgang Jenkner [this message]
2012-09-08 23:11                     ` Stefan Monnier
2012-09-09  2:51                       ` Eli Zaretskii
2012-09-09 14:44                         ` Stefan Monnier
2012-09-09 17:14                           ` Eli Zaretskii
2012-09-09 17:35                             ` Drew Adams
2012-09-09 18:20                               ` Eli Zaretskii
2012-09-09 19:46                                 ` Drew Adams
2012-09-09 21:37                             ` Stefan Monnier
2012-09-10  4:37                               ` Eli Zaretskii
2012-09-10 12:59                                 ` Stefan Monnier
2012-09-10 15:01                                   ` Stefan Monnier
2012-09-10 15:21                                   ` Drew Adams
2012-09-10 16:24                                   ` Eli Zaretskii
2012-09-09  8:25 ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=85zk4yoyto.fsf@iznogoud.viz \
    --to=wjenkner@inode.at \
    --cc=12314@debbugs.gnu.org \
    --cc=cyd@gnu.org \
    --cc=drew.adams@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.