bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#27584: 26.0.50; alist-get: Add optional arg TESTFN


From: Michael Heerdegen
Subject: bug#27584: 26.0.50; alist-get: Add optional arg TESTFN
Date: Mon, 10 Jul 2017 14:47:47 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Tino Calancha <tino.calancha@gmail.com> writes:

> I rewrote it as follows:
>
>   (declare (compiler-macro
>             (lambda (form)
>               (pcase pred
>                 (''eq `(assq ,key ,alist))
>                 ((or ''equal 'nil) `(assoc ,key ,alist))
>                 ((and (guard (macroexp-const-p key)) ''eql)
>                  (if (floatp key)
>                      `(assoc ,key ,alist) `(assq ,key ,alist)))
>                 (t form)))))

Is this a good idea in general?  PRED could also be function-quoted, or
a variable bound to `eq'.  And KEY could be an expression that evaluates
to a float.  That would fail the `floatp' test.


Michael.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]