From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#28876: 26.0; (elisp) `Hash Tables': hash table vs alist Date: Wed, 9 Oct 2019 07:47:50 -0700 (PDT) Message-ID: <24dd23c7-ae35-49d0-b570-06850bea6103@default> References: <7b57e08d-96a4-4887-bd25-afe9e9587c09@default> <87v9synwrk.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="196965"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 28876@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Oct 09 21:00:10 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iIHBx-000p5n-Ts for geb-bug-gnu-emacs@m.gmane.org; Wed, 09 Oct 2019 21:00:10 +0200 Original-Received: from localhost ([::1]:54386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iIHBw-0000De-4G for geb-bug-gnu-emacs@m.gmane.org; Wed, 09 Oct 2019 15:00:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35061) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iIDGx-0003i8-Ph for bug-gnu-emacs@gnu.org; Wed, 09 Oct 2019 10:49:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iIDGw-0006i6-Mz for bug-gnu-emacs@gnu.org; Wed, 09 Oct 2019 10:49:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45013) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iIDGw-0006hv-If for bug-gnu-emacs@gnu.org; Wed, 09 Oct 2019 10:49:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iIDGw-0003A0-Dk for bug-gnu-emacs@gnu.org; Wed, 09 Oct 2019 10:49:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 09 Oct 2019 14:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28876 X-GNU-PR-Package: emacs Original-Received: via spool by 28876-submit@debbugs.gnu.org id=B28876.157063248212060 (code B ref 28876); Wed, 09 Oct 2019 14:49:02 +0000 Original-Received: (at 28876) by debbugs.gnu.org; 9 Oct 2019 14:48:02 +0000 Original-Received: from localhost ([127.0.0.1]:53831 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iIDFx-00038P-Sk for submit@debbugs.gnu.org; Wed, 09 Oct 2019 10:48:02 -0400 Original-Received: from userp2120.oracle.com ([156.151.31.85]:38042) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iIDFv-000387-NL for 28876@debbugs.gnu.org; Wed, 09 Oct 2019 10:48:00 -0400 Original-Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x99EgTIG104639; Wed, 9 Oct 2019 14:47:53 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-2019-08-05; bh=rmVGhBxcpPXyv/UdDf3hDyiT+wwaQbek3M/mHjHmWLg=; b=aOo77NtaOvleiJmot0II0lJfBFM5DnN1Glp4mqEdPuuvlQISHHwj35564omtif0NfKEE A1fg2X0Jq3Oe82YFCvnCcjmmPFsH0y1yaQAZm8qnwKA8YE3P6h/vVgKgMW5wRhdcKdRP PPWe+mO9nikm4Y2pexzgfsaJwfTm3MtxQdjNI7zwCJeLbbMa/uUR36WQs1BgHrzx5O6e gO+focFxU3+AgqJTos41VBtStTHb+zW0s/lM7FeT0wrbfpaCtHO8FnnO31yi5OBXGDgR 4m4KWX+406AmYJQ5sHj8GIqRzDCoHh5f7uGmdoKTrpWPDxDTs1Tf0wMIjY5gUPmzApJH Kg== Original-Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2vektrmwph-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Oct 2019 14:47:53 +0000 Original-Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x99EgJeN159617; Wed, 9 Oct 2019 14:47:52 GMT Original-Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 2vh8k0w8dj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Oct 2019 14:47:52 +0000 Original-Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x99Elp6c001797; Wed, 9 Oct 2019 14:47:51 GMT In-Reply-To: <87v9synwrk.fsf@gnus.org> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4900.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9405 signatures=668684 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-1908290000 definitions=main-1910090141 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9405 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910090141 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: 209.51.188.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:168744 Archived-At: > > 1. Please consider saying explicitly that an Elisp hash table is not a > > multimap. > > > > This is another way in which it differs from an alist. An alist can > > have multiple entries that have exactly the same key (even `eq'). An > > Elisp hash table cannot - it realizes a mathematical function: one key > > gives you only one value. > > > > (The fact that `assoc' and `assq' ignore entries past the first is > > irrelevant here. An alist is a list; it can be used in many ways.) >=20 > An alist is a list that associates keys with value. There may be > several identical keys in the list, but that is not how an alist is > meant to be used, which is reflected in how the common operators on > alists work -- they only return the first match. That is _exactly_ how an alist is meant to be used. And not understanding that is precisely the problem here. The point of using an alist is that you can, and you typically will, have multiple entries with the same key, AND that only the first one is returned by the specifically-alist access functions. An alist is not a hash table, and this is one of the most important differences. > So I don't think this is a difference that needs to be pointed out here. That's unfortunate. > > 2. Wrt the difference between an alist and a hash table, the emphasis i= n > > this node seems to be on the performance characteristics. I think that > > functional/structural differences should be distinguished here from > > performance differences, instead of just lumping them together in the > > same bulleted list. >=20 > The primary difference is in the performance characteristics, so I don't > see anything that needs changing in that node. No, the primary difference is not in the performance characteristics. And even those can be more complex that what is presented here. Users used to other languages too often assume that an Emacs-Lisp hash table will be more performant than an alist, at least for a large set. Things are not so simple. The primary difference is structural. It is especially that an alist is a Lisp _list_. > Closing. That's too bad.