Subject: Re: bug#75170: add-to-alist: new function

From: Robert Pluim <[email-masked]>
Date: Tue, 21 Jan 2025 11:57:21 +0100

>>>>> On Tue, 21 Jan 2025 05:33:48 -0500, "Alfred M. Szmidt" <[email-masked]> said:

    Alfred>    "Alfred M. Szmidt" <[email-masked]> 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.

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

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

    Alfred> That seems like it cannot possibly work (or very complicated).  How do
    Alfred> you differetnate between a plist and alist?  Order in an alist is
    Alfred> important, but not in a plist.  Their syntax is exactly the same, how
    Alfred> can a insertion function work correctly for that?

map.el assumes that a list that starts with an atom is a plist, and
any other list is an alist. alist-get and assoc obviously disagree.

Robert
--