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

From: Tino Calancha <[email-masked]>
Date: Mon, 10 Jul 2017 22:02:34 +0900 (JST)

On Mon, 10 Jul 2017, Michael Heerdegen wrote:

> Tino Calancha <[email-masked]> 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.
Well, this code is now in the 'Limbo', because we are thinking
to use the Nico solution (`assoc' having an optional arg PRED).
That said, its fun to discuss about it.
You know, this compiler macro is inspired in the one used by 
`cl-assoc' i.e., `cl--compiler-macro-assoc'.  If you find a problem
on it, then the same problem might arise in `cl-assoc' :-S