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

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

bug#45539: 26.3; `add-to-ordered-list': Add optional arg for :test predi


From: Drew Adams
Subject: bug#45539: 26.3; `add-to-ordered-list': Add optional arg for :test predicate for hash table
Date: Wed, 30 Dec 2020 21:47:45 -0800 (PST)

> > It's a strange, maximally inefficient function.  I'll fix it up a bit
> > and add the test-function.
> 
> The complication is that test-function has to be the same in all calls
> (or not given at all in subsequent calls).

I don't think so.  It just needs to be applicable
for the particular kind(s) of list elements you
have.

I think you can use different TEST functions, but
I'm not sure why you'd do that.

But you raise a good point.  Because TEST needs to
be used to test list membership, as well as to be
the hash-table :test, unless the default value for
it suffices for testing list membership you need
to provide it whenever you call the function.

That's not good, and it's maybe one reason the
design hard-coded `eq'.

OK, I see now that there's `hash-table-test', which
returns the :test defined for the hash table.  We
should use that, not TEST, each time for checking
list membership, I think.

IOW, not this:

(unless (cl-member element (symbol-value list-var) :test TEST)
  (set list-var  (cons element (symbol-value list-var))))

but this:

(unless (cl-member element (symbol-value list-var)
                   :test (hash-table-test ordering))
  (set list-var  (cons element (symbol-value list-var))))





reply via email to

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