unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: bug-gnu-emacs@gnu.org
Subject: bug#5450: Variable Capturing and other problems in assoc.el
Date: Fri, 22 Jan 2010 18:53:01 +0100	[thread overview]
Message-ID: <1264182781.19724.4389@snow> (raw)

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.










             reply	other threads:[~2010-01-22 17:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-22 17:53 Michael Heerdegen [this message]
2010-01-23 22:46 ` bug#5450: Variable Capturing and other problems in assoc.el Chong Yidong

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=1264182781.19724.4389@snow \
    --to=michael_heerdegen@web.de \
    --cc=bug-gnu-emacs@gnu.org \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).