More on memq



Stavros Macrakis wrote:
> The funny thing is that in over 75% of #'eq cases, either the
> tested-member was a symbol, or the list was a quoted list of symbols,
> so a competent compiler would have required no explicit :test clause
> at all, choosing eq automatically since for symbols it is equivalent
> to eql and is more efficient. (Do any of our standard compilers handle
> this case correctly?)
>   
CMUCL (and very likely SBCL) will compile (member x '(a b c d)) to use 
eq tests.  In fact, in this case, it unrolled the loop completely and 
basically compares x to each element of the list (via eq).

For (member 'a x), CMUCL actually converts it to a call to CMUCL's memq. 
:-) 


> Oh yes, and there was one case with a carefully inserted eq-test which
> was incorrect -- it should in principle have been an eql test (I don't
> think that CL guarantees that (eq 0 0) = t).
>   
That's correct.  Fixnums are not necessarily eq.  But I think it is true 
for all of the Lisps currently supported, but in abcl fixnums are always 
boxed and therefore not eq.

Ray