Subject: bug#47368: 28.0.50; map-elt returns nil without "deprecated" TESTFN

From: Adam Porter <[email-masked]>
Date: Wed, 21 Jul 2021 10:34:14 -0500

Hi,

If I may chime in here, I'd like for map-elt to be usable with alists
having string keys.  It may not generally be very common in Elisp to
use alists with string keys, but in certain contexts, like preparing
JSON maps for encoding, it is.

In one of my packages, I came up with this workaround, which may be
tolerable when only used once in the whole package, but wouldn't be
nice to use more often:

    (cl-letf (((symbol-function 'alist-get)
               (lambda (key alist &optional _default _remove _testfn)
                 (cdr (assoc-string key alist)))))
      (let ((alist (list (cons "foo" "FOO")
                         (cons "bar" "BAR"))))
        (map-elt alist "foo")))  ;;=> "FOO"

In one of my other packages, I would have to use it more often, so I
guess I'll use alist-get for now.

In general, I think that using `equal' is a good solution.  It seems
like map-elt is intended to abstract over some Lisp implementation
details (to some extent, anyway), so using `equal' instead of `eq'
seems sensible, since I think it will usually DWIM.  If I really need
to compare Lisp object identity rather than equality, I'll probably
know how, and I probably won't need to do that as often, anyway.

Could this change be made for Emacs 28 and tagged for a 3.1 release of map.el?

Thanks,
Adam