GNU bug report logs - #8126
23.2; Improvement requests for assoc.el

Previous Next

Package: emacs;

Reported by: michael_heerdegen <at> web.de

Date: Sat, 26 Feb 2011 19:38:02 UTC

Severity: wishlist

Tags: wontfix

Found in version 23.2

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 8126 in the body.
You can then email your comments to 8126 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8126; Package emacs. (Sat, 26 Feb 2011 19:38:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to michael_heerdegen <at> web.de:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 26 Feb 2011 19:38:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 23.2; Improvement requests for assoc.el
Date: Sat, 26 Feb 2011 20:39:37 +0100
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=''





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8126; Package emacs. (Sat, 26 Feb 2011 21:10:02 GMT) Full text and rfc822 format available.

Message #8 received at 8126 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: michael_heerdegen <at> web.de
Cc: 8126 <at> debbugs.gnu.org
Subject: Re: bug#8126: 23.2; Improvement requests for assoc.el
Date: Sat, 26 Feb 2011 16:09:44 -0500
> 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  <monnier <at> iro.umontreal.ca>
+
+	* emacs-lisp/assoc.el: Remove misleading `sort' (bug#8126).
+	(aput, adelete, amake): Replace `eval' -> `symbol-value'.
+	Suggested by Michael Heerdegen <michael_heerdegen <at> web.de>.
+
 2011-02-24  Glenn Morris  <rgm <at> gnu.org>
 
 	* 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)
 





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#8126; Package emacs. (Tue, 14 Aug 2012 18:44:01 GMT) Full text and rfc822 format available.

Message #11 received at 8126 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: 8126 <at> debbugs.gnu.org
Cc: michael_heerdegen <at> web.de
Subject: Re: bug#8126: 23.2; Improvement requests for assoc.el
Date: Tue, 14 Aug 2012 14:34:41 -0400
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.




Added tag(s) wontfix. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Tue, 14 Aug 2012 18:44:01 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 8126 <at> debbugs.gnu.org and michael_heerdegen <at> web.de Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Tue, 14 Aug 2012 18:44:01 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 12 Sep 2012 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 280 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.