Add support for a compare-fn in add-to-list
Brian Palmer
bpalmer at gmail.com
Tue Feb 26 09:46:58 EST 2008
(if (member* element (symbol-value list-var)
>:test (or compare-fn #'equal))
Since subr.el is dumped before cl.el, I wanted to make sure that if anything
pre-CL did call add-to-list, it'd at least work if they avoided the :test
case. But nothing seems to, so I suppose this would be safe?
> instead? Or for efficiency (does that ever matter here?)
>
> ;; member and memq are implemented in C
> (if (cond ((eq compare-fn #'eq) (memq element (symbol-value list-var)))
> ((null compare-fn) (member element (symbol-value list-var)))
> ((member* element (symbol-value list-var) :test compare-fn)))
>
> Do we have any use cases for :test functions other than member?
>
Emacs also seems to offer a memql, but I'm not sure how much use it is other
than completism.
As for :test, it's also used in make-hash-table.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xemacs.org/pipermail/xemacs-patches/attachments/20080226/9a29f15c/attachment.htm
More information about the XEmacs-Patches
mailing list