Subject: Re: bug#47425: 26.3; `plist-get', `plist-put' should accept a TEST function

From: Lars Ingebrigtsen <[email-masked]>
Date: Sun, 28 Mar 2021 15:12:40 +0200

Drew Adams <[email-masked]> writes:

> Please consider adding a TEST comparer arg for plist keys.
>
> In Elisp, a plist key need not be a symbol:
>
> (plist-put (list "aaa" 1 "bbb" 2 "ccc" 3) "bbb" 42)
>
> That "works" (and no error), but it doesn't do what's expected, since
> the keys should be compared with `equal' or `string=', not `eq'.

plist-put doesn't ensure that the operation makes sense here, no, but we
can't really add that at this point, either.

I think adding a comparison function makes sense, but on the other
hand -- we seem to be moving towards using map.el more for these things
now, so I'm not sure there's much enthusiasm for that.  On the other
hand, the generic map functions have the problem that they...  can't
really be used like plist-put.  Sure

(map-put! (list 'a 1) 'b 2)

works fine, but you can't create a plist that way, which makes these
functions barely usable at all for handling plists/alists:

(map-put! nil 'b 2)

will signal an error.

So does anybody have an opinion here?  I think I'm in favour of adding a
comparison function for all three `plist-*' functions.

Drew Adams <[email-masked]> writes:

> That would also mean we wouldn't need `lax-plist-*' functions.

Yes, those are horrible functions, and are barely used anywhere.  (And
`lax-plist-member' is missing.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no