From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: plists, alists, and hashtables Date: Fri, 07 Aug 2015 12:32:28 -0400 Message-ID: References: <876150vwaa.fsf@mbork.pl> <873803x5q4.fsf@kuiper.lan.informatimago.com> <87a8u7we9s.fsf_-_@lifelogs.com> <877fp8t9ru.fsf@lifelogs.com> <87lhdnsw2n.fsf@lifelogs.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1438965185 24157 80.91.229.3 (7 Aug 2015 16:33:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 7 Aug 2015 16:33:05 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Aug 07 18:32:57 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZNkZj-0003NJ-Ol for geh-help-gnu-emacs@m.gmane.org; Fri, 07 Aug 2015 18:32:56 +0200 Original-Received: from localhost ([::1]:49903 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNkZi-0003Gn-Pr for geh-help-gnu-emacs@m.gmane.org; Fri, 07 Aug 2015 12:32:54 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNkZX-0003GZ-CQ for help-gnu-emacs@gnu.org; Fri, 07 Aug 2015 12:32:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZNkZS-0005PX-A4 for help-gnu-emacs@gnu.org; Fri, 07 Aug 2015 12:32:43 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:52489) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNkZS-0005PF-2T for help-gnu-emacs@gnu.org; Fri, 07 Aug 2015 12:32:38 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZNkZQ-00036q-F4 for help-gnu-emacs@gnu.org; Fri, 07 Aug 2015 18:32:36 +0200 Original-Received: from 157-52-5-248.cpe.teksavvy.com ([157.52.5.248]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 07 Aug 2015 18:32:36 +0200 Original-Received: from monnier by 157-52-5-248.cpe.teksavvy.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 07 Aug 2015 18:32:36 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 34 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 157-52-5-248.cpe.teksavvy.com User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) Cancel-Lock: sha1:ZKrHJVOZ6GpyDaeJwkToz6GOdN8= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:106320 Archived-At: > I am showing how extracting the keys of an alist can generate *runtime* > errors, when the alist has already been read in. Which makes actual > maps more appealing, I thought, because they could avoid that problem at > the reader level. I'd estimate that it would catch 0.05% of the errors a bit earlier, yes. > Right. I agree. My point was different: there is no "keys" function for > alists and plists. (mapcar #'car ...) *is* the "keys" function for alists. You could define it as `alist-keys', or use `map-keys' from map.el for that. The only reason why it's never been defined so far is because (mapcar #'car ...) is quite sufficient since extracting the list/set of keys of a map is a rare operation. > Keys in those two formats are a convention. Yes but one you can rely on. I think what you're getting at is that (core) Lisp is somewhat "untyped", so alists/plists can't be distinguished from other data built using cons-cells: only the user knows whether that cons cells is meant to be an alist or a plist or something else. > I certainly see the advantages of appending instead of modifying in > place. I think that's an artifact of the current hashtable API, not a > fundamental property of maps or hashtables. There are persistent hash-tables, indeed, but they typically use some kind of tree/trie rather than one big hashing array. Stefan