all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 45539@debbugs.gnu.org
Subject: bug#45539: 26.3; `add-to-ordered-list': Add optional arg for :test predicate for hash table
Date: Thu, 31 Dec 2020 08:40:00 -0800 (PST)	[thread overview]
Message-ID: <790c4820-62b2-41af-81ac-d3a2a98bbae3@default> (raw)
In-Reply-To: <97ab6ba6-210a-4b72-9350-00e30c28d0e1@default>

I just now noticed the doc for this function in (elisp)
`List Variables'.  Should have looked in that manual
sooner.  (I didn't expect it to be documented there;
never heard of this function before.)

That description confirms what I've said, I think.

Dunno why this function was added (and documented in
the manual, which is usually done only for important
functions).  Dunno if anyone uses it.
___

One thing that I've said isn't quite correct: the
list _can_ have duplicates for elements that are
added with no ORDER.  IOW, I should have said that
elements that are recorded in the hash table can't
be duplicated (because a hash table has unique keys).
But other elements can be duplicated.
___

If we're adding a TEST optional arg, to accommodate
hash-table and list membership checks, maybe we should
allow callers to specify a :key arg as well.  In that
case, instead of adding optional TEST and KEY args we
would presumably want to use `cl-defun' and allow
keyword args :test and :key.

What do you think?  I realize that this now is about
redesigning this function a bit, and we (I, at least)
have little knowledge of why this function was added.

Still, it seems like its basic purpose would benefit
from letting you use different :key as well as :test.
___

Until I discovered that the function was in the manual
I was wondering, since this function seems so messed up
and unclear, if we should just remove it.  Now I think
we should maybe just fix it by using `cl-defun'.

Another thing (maybe even the main thing) that's
confusing about this function is its name.

This function is about a special kind of ordering:
the "order" you specify for an element is more of a
kind of "score".  It doesn't directly reflect
(correspond to) the list position of an element.
And the function is not so much about adding an
an element to a list as it is recording the score of
an element (a score used to determine its order in the
list).  And besides the function being able to record
such a score for an element, it can also _remove_ its
score.  (So it's not even necessarily about "adding"
a score.
___

Googling for this function (which is how I accidentally
came across it in the Elisp manual), I see that others
have been confused by its behavior and (IIUC) its aim.
E.g.:

https://stackoverflow.com/q/22440069/729907

I've added an answer to that question here, to clarify
some of its confusion.

https://stackoverflow.com/a/65523104/729907

And I've added a clarification answer to the emacs.SE
question (which provoked this bug report), as well:

https://emacs.stackexchange.com/a/62542/105





  reply	other threads:[~2020-12-31 16:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-29 21:04 bug#45539: 26.3; `add-to-ordered-list': Add optional arg for :test predicate for hash table Drew Adams
2020-12-30  3:48 ` Lars Ingebrigtsen
2020-12-30  7:01   ` Drew Adams
2020-12-30  7:07     ` Lars Ingebrigtsen
2020-12-30  8:43       ` Drew Adams
2020-12-30 17:55         ` Drew Adams
2020-12-31  3:55           ` Lars Ingebrigtsen
2020-12-31  4:30             ` Lars Ingebrigtsen
2020-12-31  5:47               ` Drew Adams
2020-12-31 16:40                 ` Drew Adams [this message]
2020-12-31  5:34             ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=790c4820-62b2-41af-81ac-d3a2a98bbae3@default \
    --to=drew.adams@oracle.com \
    --cc=45539@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.