From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs 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) Message-ID: <790c4820-62b2-41af-81ac-d3a2a98bbae3@default> References: <1af7f2ac-0e6c-4c8a-860b-22148265d8aa@default> <87y2hgosxo.fsf@gnus.org> <64015d41-a84f-4ff6-a5a1-ab5d92aa20e5@default> <87k0szpyaj.fsf@gnus.org> <87v9ciociu.fsf@gnus.org> <87r1n6oawn.fsf@gnus.org> <97ab6ba6-210a-4b72-9350-00e30c28d0e1@default> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29616"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 45539@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 31 17:41:19 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kv10o-0007cK-PB for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 31 Dec 2020 17:41:18 +0100 Original-Received: from localhost ([::1]:53920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kv10n-0006WN-P8 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 31 Dec 2020 11:41:17 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kv10Y-0006Sr-V6 for bug-gnu-emacs@gnu.org; Thu, 31 Dec 2020 11:41:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58151) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kv10Y-0001kZ-HG for bug-gnu-emacs@gnu.org; Thu, 31 Dec 2020 11:41:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kv10Y-0002DP-FR for bug-gnu-emacs@gnu.org; Thu, 31 Dec 2020 11:41:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 31 Dec 2020 16:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45539 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed Original-Received: via spool by 45539-submit@debbugs.gnu.org id=B45539.16094328158432 (code B ref 45539); Thu, 31 Dec 2020 16:41:02 +0000 Original-Received: (at 45539) by debbugs.gnu.org; 31 Dec 2020 16:40:15 +0000 Original-Received: from localhost ([127.0.0.1]:41461 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kv0zn-0002Bv-5Y for submit@debbugs.gnu.org; Thu, 31 Dec 2020 11:40:15 -0500 Original-Received: from userp2130.oracle.com ([156.151.31.86]:51516) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kv0zl-0002Bi-BH for 45539@debbugs.gnu.org; Thu, 31 Dec 2020 11:40:14 -0500 Original-Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0BVGZ8lg011505; Thu, 31 Dec 2020 16:40:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=CyRGS1sd9GLls7sQt+L0rKhZn6/SFS0P7bkjJGe90uM=; b=CfXI2a2i69rSv9+JDqzVNaPYC0Lc4VkE/h5AHMHHASsDmlM8W6x4Gu3Impi1ohYGR5u1 D/wxwOzyMD0doLo91CTPGJryQvaaC99CXsa9Hxrs1t3772xjiJmuQdj6Xe4SsY4Ywqr4 +7WUzGxrddmy31ADrPmKOGteqxakRu3XtmT/UUl6tUBPUJgMkGmZheZUOJX5L736LlUY VXOKKWP+DCzhZUGLuzwU13rVENKctAai48ec7UWbOnI7/BxLB3u5GeGChwl1H+RCCSq6 50REyajFDGnblx5XPHB/zyy0mXX2mDRB9APcUU8ocZNOM4p5O0L1TpE8kBMJ+75Ix53A 6g== Original-Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 35nvkqugeb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 31 Dec 2020 16:40:06 +0000 Original-Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0BVGe5mG144152; Thu, 31 Dec 2020 16:40:06 GMT Original-Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 35pexu8tvq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 31 Dec 2020 16:40:05 +0000 Original-Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0BVGe1b6008273; Thu, 31 Dec 2020 16:40:01 GMT In-Reply-To: <97ab6ba6-210a-4b72-9350-00e30c28d0e1@default> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.5095.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9851 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 spamscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012310101 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9851 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 adultscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012310100 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:197100 Archived-At: 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