From unknown Tue Jun 17 22:19:15 2025 X-Loop: help-debbugs@gnu.org Subject: bug#8126: 23.2; Improvement requests for assoc.el Resent-From: Michael Heerdegen Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 26 Feb 2011 19:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 8126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 8126@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Reply-To: michael_heerdegen@web.de Received: via spool by submit@debbugs.gnu.org id=B.129874904113539 (code B ref -1); Sat, 26 Feb 2011 19:38:02 +0000 Received: (at submit) by debbugs.gnu.org; 26 Feb 2011 19:37:21 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PtPxA-0003WK-NA for submit@debbugs.gnu.org; Sat, 26 Feb 2011 14:37:20 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PtPx8-0003Vw-Ba for submit@debbugs.gnu.org; Sat, 26 Feb 2011 14:37:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PtPx2-0001Rm-LO for submit@debbugs.gnu.org; Sat, 26 Feb 2011 14:37:13 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,T_RP_MATCHES_RCVD,T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:46694) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PtPx2-0001Rg-JN for submit@debbugs.gnu.org; Sat, 26 Feb 2011 14:37:12 -0500 Received: from [140.186.70.92] (port=44668 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PtPx1-0001JO-Hq for bug-gnu-emacs@gnu.org; Sat, 26 Feb 2011 14:37:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PtPx0-0001RL-6u for bug-gnu-emacs@gnu.org; Sat, 26 Feb 2011 14:37:11 -0500 Received: from fmmailgate01.web.de ([217.72.192.221]:40493) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PtPwz-0001RD-Oq for bug-gnu-emacs@gnu.org; Sat, 26 Feb 2011 14:37:10 -0500 Received: from smtp04.web.de ( [172.20.0.225]) by fmmailgate01.web.de (Postfix) with ESMTP id 9CE9018A2617B for ; Sat, 26 Feb 2011 20:37:07 +0100 (CET) Received: from [94.216.100.121] (helo=dragon) by smtp04.web.de with asmtp (WEB.DE 4.110 #2) id 1PtPwx-0002y5-00 for bug-gnu-emacs@gnu.org; Sat, 26 Feb 2011 20:37:07 +0100 From: Michael Heerdegen Date: Sat, 26 Feb 2011 20:39:37 +0100 Message-ID: <86d3me37ra.fsf@web.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Sender: michael_heerdegen@web.de X-Provags-ID: V01U2FsdGVkX18rkda9UsMEs5ZKhklvnriN8O+OuovEgHzWGJq1 h+5xUjuhj7R4JaQ0KEWjeU8eqZmXTzSBNasCNHNnvnHPr/uxSG YeJRgf7VKBRRGISISKVA== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 199.232.76.165 X-Spam-Score: -6.6 (------) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.6 (------) Hello Emacs, assoc.el, a library providing functions on association lists, is part of GNU Emacs. My requests: 1. Please mention this lib in the Elisp Manual. assoc.el provides some essential elementary functions for alists. These should be mentioned in the Elisp Manual (at least `aput', `adelete') under "Association Lists". 2. Please remove the misleading word `sort' from the header descriptions. This file doesn't include any function for sorting alists. There is `asort', but it actually doesn't sort the alist, it only moves an element with a given KEY to the head of the alist. 3. Most of the functions in this library use `asort' (same file) as a helper. `asort' uses `sort' only to put a cons cell with a given key to the head of the alist. This is very inefficient. Thus, `aput', `adelete', `aget' and `amake' have a bad run-time behavior. Even worse, `amake' uses `aput', thus sorts the alist built so far in recursion. There is a package in apel called "alist.el" which provides very similar functions. You can use it as a reference. 4. `eval' -> `symbol-value' All occurrences of `eval' can be replaced with `symbol-value'. 5. There are currently no autoload cookies in "assoc.el". Maybe they should be added. Thanks, Michael. In GNU Emacs 23.2.1 (i486-pc-linux-gnu, GTK+ Version 2.20.0) of 2010-12-11 on raven, modified by Debian Windowing system distributor `The X.Org Foundation', version 11.0.10707000 configured using `configure '--build' 'i486-linux-gnu' '--build' 'i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.2/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/23.2/leim' '--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars' 'build_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN -g -O2' 'LDFLAGS=-g' 'CPPFLAGS='' From unknown Tue Jun 17 22:19:15 2025 X-Loop: help-debbugs@gnu.org Subject: bug#8126: 23.2; Improvement requests for assoc.el Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 26 Feb 2011 21:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: michael_heerdegen@web.de Cc: 8126@debbugs.gnu.org Received: via spool by 8126-submit@debbugs.gnu.org id=B8126.129875459221326 (code B ref 8126); Sat, 26 Feb 2011 21:10:02 +0000 Received: (at 8126) by debbugs.gnu.org; 26 Feb 2011 21:09:52 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PtROi-0005Xu-D1 for submit@debbugs.gnu.org; Sat, 26 Feb 2011 16:09:52 -0500 Received: from ironport2-out.teksavvy.com ([206.248.154.183] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PtROh-0005Xh-4i for 8126@debbugs.gnu.org; Sat, 26 Feb 2011 16:09:51 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEADP7aE1FpZIs/2dsb2JhbACmRXW7B4VhBIUQj18 X-IronPort-AV: E=Sophos;i="4.62,232,1297054800"; d="scan'208";a="93670866" Received: from 69-165-146-44.dsl.teksavvy.com (HELO ceviche.home) ([69.165.146.44]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 26 Feb 2011 16:09:44 -0500 Received: by ceviche.home (Postfix, from userid 20848) id A7333660D6; Sat, 26 Feb 2011 16:09:44 -0500 (EST) From: Stefan Monnier Message-ID: References: <86d3me37ra.fsf@web.de> Date: Sat, 26 Feb 2011 16:09:44 -0500 In-Reply-To: <86d3me37ra.fsf@web.de> (Michael Heerdegen's message of "Sat, 26 Feb 2011 20:39:37 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.1 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) > 1. Please mention this lib in the Elisp Manual. > assoc.el provides some essential elementary functions for alists. > These should be mentioned in the Elisp Manual (at least `aput', > `adelete') under "Association Lists". It seems to be very little used. Maybe it's for lack of exposure, but maybe it's because the functionality is not often needed. So I'm not convinced it needs to be advertised much more (especially given its current state, as discussed below). > 2. Please remove the misleading word `sort' from the header > descriptions. > This file doesn't include any function for sorting alists. There is > `asort', but it actually doesn't sort the alist, it only moves an > element with a given KEY to the head of the alist. Another way to fix it would be to provide a sort function, tho I guess `sort' works just fine. > 3. Most of the functions in this library use `asort' (same file) as a > helper. `asort' uses `sort' only to put a cons cell with a given key > to the head of the alist. This is very inefficient. Thus, `aput', > `adelete', `aget' and `amake' have a bad run-time behavior. Patch welcome. > 4. `eval' -> `symbol-value' > All occurrences of `eval' can be replaced with `symbol-value'. Indeed. Abuse of `eval' is something I really dislike. Using `symbol-value' is much better, tho I'd even much prefer using `cdr' instead (i.e. not (ab)use symbols but a cons-cell with a well-known car value, such as `alist' or somesuch). > 5. There are currently no autoload cookies in "assoc.el". Maybe they > should be added. `assoc.el' is currently meant to be included with (require 'assoc) and I think it works well that way. For now, I've installed the patch below, Thanks, Stefan === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-02-24 08:45:25 +0000 +++ lisp/ChangeLog 2011-02-26 21:07:45 +0000 @@ -1,3 +1,9 @@ +2011-02-26 Stefan Monnier + + * emacs-lisp/assoc.el: Remove misleading `sort' (bug#8126). + (aput, adelete, amake): Replace `eval' -> `symbol-value'. + Suggested by Michael Heerdegen . + 2011-02-24 Glenn Morris * files-x.el (modify-dir-local-variable): Handle dir-locals from === modified file 'lisp/emacs-lisp/assoc.el' --- lisp/emacs-lisp/assoc.el 2011-01-25 04:08:28 +0000 +++ lisp/emacs-lisp/assoc.el 2011-02-26 21:02:38 +0000 @@ -1,4 +1,4 @@ -;;; assoc.el --- insert/delete/sort functions on association lists +;;; assoc.el --- insert/delete functions on association lists ;; Copyright (C) 1996, 2001-2011 Free Software Foundation, Inc. @@ -35,7 +35,7 @@ the order of any other key-value pair. Side effect sets alist to new sorted list." (set alist-symbol - (sort (copy-alist (eval alist-symbol)) + (sort (copy-alist (symbol-value alist-symbol)) (function (lambda (a b) (equal (car a) key)))))) @@ -75,7 +75,7 @@ (lexical-let ((elem (aelement key value)) alist) (asort alist-symbol key) - (setq alist (eval alist-symbol)) + (setq alist (symbol-value alist-symbol)) (cond ((null alist) (set alist-symbol elem)) ((anot-head-p alist key) (set alist-symbol (nconc elem alist))) (value (setcar alist (car elem))) @@ -87,7 +87,7 @@ Alist is referenced by ALIST-SYMBOL and the key-value pair to remove is pair matching KEY. Returns the altered alist." (asort alist-symbol key) - (lexical-let ((alist (eval alist-symbol))) + (lexical-let ((alist (symbol-value alist-symbol))) (cond ((null alist) nil) ((anot-head-p alist key) alist) (t (set alist-symbol (cdr alist)))))) @@ -133,7 +133,7 @@ (t (amake alist-symbol keycdr valcdr) (aput alist-symbol keycar valcar)))) - (eval alist-symbol)) + (symbol-value alist-symbol)) (provide 'assoc) From unknown Tue Jun 17 22:19:15 2025 X-Loop: help-debbugs@gnu.org Subject: bug#8126: 23.2; Improvement requests for assoc.el Resent-From: Glenn Morris Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 14 Aug 2012 18:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 8126@debbugs.gnu.org Cc: michael_heerdegen@web.de Received: via spool by 8126-submit@debbugs.gnu.org id=B8126.134496980331881 (code B ref 8126); Tue, 14 Aug 2012 18:44:01 +0000 Received: (at 8126) by debbugs.gnu.org; 14 Aug 2012 18:43:23 +0000 Received: from localhost ([127.0.0.1]:56857 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T1M5L-0008I9-2N for submit@debbugs.gnu.org; Tue, 14 Aug 2012 14:43:23 -0400 Received: from fencepost.gnu.org ([208.118.235.10]:49329) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T1M5J-0008Hz-Q0; Tue, 14 Aug 2012 14:43:22 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1T1Lww-0004qt-35; Tue, 14 Aug 2012 14:34:42 -0400 From: Glenn Morris References: <86d3me37ra.fsf@web.de> X-Spook: Etacs Telex Semtex Syria NWO rs9512c argus CISU X-Ran: gv3;).(Xux'MA7/p6iCTQYRTXw(#\2xcjXSZm]Fh`^)1yQE$c>h<.w,SDUs3)by^Bsub*X X-Hue: yellow X-Attribution: GM Date: Tue, 14 Aug 2012 14:34:41 -0400 In-Reply-To: (Stefan Monnier's message of "Sat, 26 Feb 2011 16:09:44 -0500") Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -6.9 (------) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) tags 8126 wontfix close 8126 stop In Emacs trunk, assoc.el has been moved to lisp/obsolete. So it won't be getting any further documentation or improvements.