[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#47425: 26.3; `plist-get', `plist-put' should accept a TEST function
From: |
Lars Ingebrigtsen |
Subject: |
bug#47425: 26.3; `plist-get', `plist-put' should accept a TEST function |
Date: |
Sun, 28 Mar 2021 15:12:40 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Drew Adams <drew.adams@oracle.com> 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 <drew.adams@oracle.com> 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