GNU bug report logs - #75170
add-to-alist: new function

Previous Next

Package: emacs;

Reported by: Roland Winkler <winkler <at> gnu.org>

Date: Sun, 29 Dec 2024 05:35:02 UTC

Severity: wishlist

Full log


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

From: "Alfred M. Szmidt" <ams <at> gnu.org>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: winkler <at> gnu.org, monnier <at> gnu.org, 75170 <at> debbugs.gnu.org,
 stefankangas <at> gmail.com, eliz <at> gnu.org, acorallo <at> gnu.org
Subject: Re: bug#75170: add-to-alist: new function
Date: Tue, 21 Jan 2025 05:33:50 -0500
   >>>>> On Tue, 21 Jan 2025 03:12:43 -0600, Stefan Kangas <stefankangas <at> gmail.com> said:

       Stefan> "Alfred M. Szmidt" <ams <at> gnu.org> writes:
       >> map-put! does not work well with alists that are not 'proper':
       >> 
       ELISP> (setq x (list 1 '(2 . 3)))
       >> (1 (2 . 3))
       >> 
       >> Why should it work on alists at all?  map-put! assumes a map (where is
       >> this structure documented? I did not see anything in the Elisp
       >> manual), not an alist.  Invalid alists will also not work on functions
       >> that assume alists.

   "invalid alists" is not something that Emacs really cares about:

Right, so why should map-foo care about such lists?  You're saying it
"expects" them to be alists, but if it gets another list that is not
an alist .. it fails.  That is the same behaviour as rest of Emacs,
no?

   ELISP> (setq y '(1 (2 . 4) 3))
   (1 (2 . 4) 3)

   ELISP> (assoc 2 y)
   (2 . 4)

   ELISP> (setf (alist-get 2 y) 66)
   66
    (#o102, #x42, ?B)
   ELISP> (assoc 2 y)
   (2 . 66)

   ELISP> y
   (1 (2 . 66) 3)

       Stefan> According to M-x describe-package RET map RET:

       Stefan> map.el provides generic map-manipulation functions that work on
       Stefan> alists, plists, hash-tables, and arrays.  All functions are
       Stefan> prefixed with "map-".

   Yes. Except that map.el expects alists to be 'proper'.




This bug report was last modified 142 days ago.

Previous Next


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