From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.devel Subject: Re: assoc-delete-all Date: Sun, 3 Jul 2005 02:52:34 +0200 Message-ID: References: <42C7300C.8050104@student.lu.se> Reply-To: Juanma Barranquero NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1120352303 6143 80.91.229.2 (3 Jul 2005 00:58:23 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 3 Jul 2005 00:58:23 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jul 03 02:58:20 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Dosnt-0002oo-S3 for ged-emacs-devel@m.gmane.org; Sun, 03 Jul 2005 02:57:50 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Dosp1-0003pi-TG for ged-emacs-devel@m.gmane.org; Sat, 02 Jul 2005 20:58:59 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Dosnz-0003XS-K8 for emacs-devel@gnu.org; Sat, 02 Jul 2005 20:57:59 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Dosnw-0003VZ-2E for emacs-devel@gnu.org; Sat, 02 Jul 2005 20:57:54 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Dosnv-0003U4-Pv for emacs-devel@gnu.org; Sat, 02 Jul 2005 20:57:51 -0400 Original-Received: from [64.233.182.198] (helo=nproxy.gmail.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DosoG-0002cx-Ls for emacs-devel@gnu.org; Sat, 02 Jul 2005 20:58:12 -0400 Original-Received: by nproxy.gmail.com with SMTP id i2so113809nfe for ; Sat, 02 Jul 2005 17:52:34 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=OxguUNZ0hObEeeOiQaBdDRW3rjNymRdhFepZOMamGa+FKX06uwiTI+21FSn4ua+oHvjJu3MwPUm8TmqhiXx8Elv6BTi9jkxJbuzl30Whs+sTwYgr7sU4FUFSLd5nv+R+jfeo+GnRHwK3CLiVJ00rWl2GgZzIVNcMtKvLlIZhlbk= Original-Received: by 10.48.249.6 with SMTP id w6mr77393nfh; Sat, 02 Jul 2005 17:52:34 -0700 (PDT) Original-Received: by 10.48.250.5 with HTTP; Sat, 2 Jul 2005 17:52:34 -0700 (PDT) Original-To: Lennart Borgman In-Reply-To: <42C7300C.8050104@student.lu.se> Content-Disposition: inline X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:40166 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:40166 > There is an assq-delete-all, but I am missing assoc-delete-all ... or, > am I missing something (else)? If I had to guess, I'd say that is because `assq-delete-all' has only one reasonable behavior, i.e., as it modifies the structure, you usually are going to do (setq alist (assq-delete-all 'my-key alist)) or directly construct the alist, filter it through `assq-delete-all' and then discard it. With `assoc-delete-all' you have to decide whether you want a shallow or a deep copy, for example: (defun assoc-delete-all (key alist) (let (l) (while alist (unless (and (consp (car alist)) (eq key (caar alist))) (setq l (cons (car alist) l))) (setq alist (cdr alist))) (nreverse l))) will do what you want, but it will still share conses with the original list. Other implementations can use `copy-tree' or `copy-alist', but really, there's no one answer that is good for every situation. Kent M. Pitman did a wonderful article about this issue (he was speaking of copy) a long time ago: "The Best of Intentions: EQUAL Rights--and Wrongs--in Lisp", http://www.nhplace.com/kent/PS/EQUAL.html --=20 /L/e/k/t/u