From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#28753: 25.3; Functions to get alist from hash table and vice versa Date: Sun, 4 Mar 2018 16:01:53 -0800 (PST) Message-ID: <96840423-b3ba-4c4b-96d5-59a26d3e2455@default> References: <54ecd1bb-0c84-4b0a-b19e-3a89cbe832bc@default> <94d02ad7-d069-4195-b84a-13229dfa3e9a@default> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1520208079 3018 195.159.176.226 (5 Mar 2018 00:01:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 5 Mar 2018 00:01:19 +0000 (UTC) Cc: 28753@debbugs.gnu.org To: Philipp Stephani Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Mar 05 01:01:15 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esdZ1-00088u-AY for geb-bug-gnu-emacs@m.gmane.org; Mon, 05 Mar 2018 01:01:11 +0100 Original-Received: from localhost ([::1]:46499 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1esdb3-00050f-MZ for geb-bug-gnu-emacs@m.gmane.org; Sun, 04 Mar 2018 19:03:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1esdar-00050Q-Ud for bug-gnu-emacs@gnu.org; Sun, 04 Mar 2018 19:03:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1esdao-0001Dl-QH for bug-gnu-emacs@gnu.org; Sun, 04 Mar 2018 19:03:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:36964) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1esdao-0001DX-Me for bug-gnu-emacs@gnu.org; Sun, 04 Mar 2018 19:03:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1esdao-0002n5-D6 for bug-gnu-emacs@gnu.org; Sun, 04 Mar 2018 19:03: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: Mon, 05 Mar 2018 00:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28753 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 28753-submit@debbugs.gnu.org id=B28753.152020812510643 (code B ref 28753); Mon, 05 Mar 2018 00:03:02 +0000 Original-Received: (at 28753) by debbugs.gnu.org; 5 Mar 2018 00:02:05 +0000 Original-Received: from localhost ([127.0.0.1]:44857 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esdZs-0002lb-Ki for submit@debbugs.gnu.org; Sun, 04 Mar 2018 19:02:04 -0500 Original-Received: from userp2120.oracle.com ([156.151.31.85]:53662) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esdZq-0002l6-8h for 28753@debbugs.gnu.org; Sun, 04 Mar 2018 19:02:03 -0500 Original-Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w2501u6R030845; Mon, 5 Mar 2018 00:01:56 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-2017-10-26; bh=8RopupvkpPAQS93SX3UIWYzXUhJum7199MDcJVA/VE0=; b=vB+p87Cp8O/7xYODyRTwP/9uPRj9lPGcrwZ6I0W4dxaV95k/B1f4DMmorfZe3qD3Pa+Y o1H1pvOUuyopt+jfTFQts809Xg4LSDlt5b4w/Ehc7+WGJTIX23euzQaWwFhCPbt9J8k5 +1pG4y3BTbOjfdG7/slxDODMRd53iOJcgNtlhBiLzELaj8C3uo7zrK9rFDcMK3gSHYrh ihnHBfhwhmvKYyKBg/BgDV8TmbYOwS0/pIo6jimVxd0/bD2tSSy1B9B3EIV37w1Akt1Z NhzLd/ry6EWW7+YDxOZAb7r6z9ijPdBaxYzf1OEsjdkNSDkL5rWMoEP9SC3e1D6+Yspg vw== Original-Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2ggtaa01u9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Mar 2018 00:01:56 +0000 Original-Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w2501tVb014774 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Mar 2018 00:01:55 GMT Original-Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w2501sY9008172; Mon, 5 Mar 2018 00:01:55 GMT In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4654.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8822 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803040312 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:143909 Archived-At: >> Order is quite important for alists, generally. >> Is there some reason we should not be able to count on >> this `maphash' behavior? > > Order in hashtables is not guaranteed. If anything relies > on the order, it's buggy. =C2=A0 Emacs hash tables don't fall from the sky. They are not shadows of some Platonic ideal. This is a design choice. Emacs Lisp can implement hash tables any way it wants. >> I don't know whether it is guaranteed, but this use case >> involving conversion to alist looks like a good argument >> for some guarantee wrt order. > > No. Ordering guarantees require additional complexity and > overhead, and are almost never needed. Neither of those assertions has been demonstrated. Feel free to do so (how much overhead, how infrequent). And infrequency of use is not, alone, a good reason not to support something. Infrequent does not mean unimportant. >> Another possibility (?): Allow _optional_ creation of >> a hash table that does preserve such ordering (even if >> just by recording order of entry and making that >> available to `maphash'). E.g., add a keyword arg for >> `make-hash-table' that does just that. >> >> Even if it turned out that this consistently or occasionally >> detracted from performance, it could be a useful option. >> Conversion to an alist would be a case in point. > > I don't think it would be worth the additional complexity. Why? How much additional complexity? > Hash tables have been available for ages in most programming > languages, and almost never does anybody ask for ordering > guarantees. (For example, I have never seen somebody using > LinkedHashMap in Java.) Emacs Lisp has lots of features that are not in "most programming languages". Propertized strings, for one trivial example. > Even for alists, most of the time maintaining insertion > order is an irrelevant detail, What time maintaining insertion order? I can't imagine what you mean by that. > most users care only about get/put/remove. Not demonstrated. But even if it were true, it wouldn't follow that Lisp alist order is unimportant. Next you'll be suggesting that because lists are mutated relatively infrequently it is unimportant to be able to modify list structure or test cons equality with `eq'. Or that because true lists are used most of the time we might as well drop support of dotted lists. ---- Naive google search - https://www.javaspecialists.eu/archive/Issue073.html https://stackoverflow.com/questions/12998568/hashmap-vs-linkedhashmap-perfo= rmance-in-iteration-over-values/12998878 https://stackoverflow.com/questions/26623129/when-to-use-linkedhashmap-over= -hashmap-in-java