GNU bug report logs - #5450
Variable Capturing and other problems in assoc.el

Previous Next

Package: emacs;

Reported by: michael_heerdegen <at> web.de

Date: Fri, 22 Jan 2010 18:08:01 UTC

Severity: normal

Done: Chong Yidong <cyd <at> stupidchicken.com>

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 5450 in the body.
You can then email your comments to 5450 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#5450; Package emacs. (Fri, 22 Jan 2010 18:08: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. (Fri, 22 Jan 2010 18:08: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: Variable Capturing and other problems in assoc.el
Date: Fri, 22 Jan 2010 18:53:01 +0100
Hello,

In the code of assoc.el, local variables in the functions `aput',
`adelete' and `amake' may hide the alist-symbol in the `eval'-clauses,
which produces wrong results.

Example:
(tested with my Emacs 22 -Q, and also with the current CVS version of
assoc.el):



ELISP> (require 'assoc)
assoc

ELISP> (setq alist '(("a" . 1) ("b" . 2)))
(("a" . 1)
 ("b" . 2))

ELISP> (setq blist '(("a" . 1) ("b" . 2)))
(("a" . 1)
 ("b" . 2))

ELISP> (aput 'alist "a" 123456)
(("a" . 123456))

ELISP> (aput 'blist "a" 123456)
("a" . 123456)

ELISP> alist
(("a" . 1)
 ("b" . 2))

ELISP> blist
(("a" . 123456)
 ("b" . 2))


------


ELISP> (setq alist '(("a" . 1) ("b" . 2)))
(("a" . 1)
 ("b" . 2))

ELISP> (setq blist '(("a" . 1) ("b" . 2)))
(("a" . 1)
 ("b" . 2))

ELISP> (adelete 'alist "a")
(("b" . 2))

ELISP> (adelete 'blist "a")
(("b" . 2))

ELISP> alist
(("a" . 1)
 ("b" . 2))

ELISP> blist
(("b" . 2))

---

Another thing: the doc of `aelement' is misleading in my opinion:

  aelement is a compiled Lisp function in `assoc.el'.
  (aelement KEY VALUE)

  Makes a list of a cons cell containing car of KEY and cdr of VALUE.
  The returned list is suitable as an element of an alist.

The returned value is an one element list with a cons cell, suitable
for `nconc', but not directly as an element of an alist.

---

It is also not fine that `amake' doesn't assign to unbound symbols:

ELISP> (amake 'clist '("a" "b") '(1 2))
*** Eval error ***  Symbol's value as variable is void: clist

so the package misses a real alist constructor.








Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5450; Package emacs. (Sat, 23 Jan 2010 22:48:01 GMT) Full text and rfc822 format available.

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

From: Chong Yidong <cyd <at> stupidchicken.com>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 5450 <at> debbugs.gnu.org
Subject: Re: Variable Capturing and other problems in assoc.el
Date: Sat, 23 Jan 2010 17:46:55 -0500
> In the code of assoc.el, local variables in the functions `aput',
> `adelete' and `amake' may hide the alist-symbol in the `eval'-clauses,
> which produces wrong results.

Fixed, thanks.




bug closed, send any further explanations to michael_heerdegen <at> web.de Request was from Chong Yidong <cyd <at> stupidchicken.com> to control <at> debbugs.gnu.org. (Sat, 23 Jan 2010 22:48:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <bug-gnu-emacs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 21 Feb 2010 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 15 years and 116 days ago.

Previous Next


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