From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.help Subject: plists, alists, and hashtables (was: How to iterate over properties in a plist?) Date: Tue, 04 Aug 2015 06:15:27 -0400 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <87a8u7we9s.fsf_-_@lifelogs.com> References: <876150vwaa.fsf@mbork.pl> <873803x5q4.fsf@kuiper.lan.informatimago.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1438683620 4550 80.91.229.3 (4 Aug 2015 10:20:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 4 Aug 2015 10:20:20 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Aug 04 12:20:20 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 1ZMZKV-0003yy-3T for geh-help-gnu-emacs@m.gmane.org; Tue, 04 Aug 2015 12:20:19 +0200 Original-Received: from localhost ([::1]:34464 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMZKT-0007Bq-PF for geh-help-gnu-emacs@m.gmane.org; Tue, 04 Aug 2015 06:20:17 -0400 Original-Path: usenet.stanford.edu!goblin1!goblin.stu.neva.ru!news.albasani.net!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 31 Original-X-Trace: news.albasani.net 189MUCLNFMZCrNIt8wBDHs11qFBUcdcV/jkaxDM5xEvIiiDJgzEPqjLKr+SDLJyIXwe74naGPlaGAvJO5Os7qQ== Original-NNTP-Posting-Date: Tue, 4 Aug 2015 10:15:30 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="WaeuQd6mMUd8DT2EF15PVmIwlQt8LyksV5vFjiiZKobiwGkeYcT3hYW35GXDcSN2Jb7V4uKog7d6dN1nXVrRGKz9+swBeIRY1aNgtsqohIamFCG8mKdt8Y/snkJk7p8a"; mail-complaints-to="abuse@albasani.net" User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux) X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" Cancel-Lock: sha1:gshXZ2cFlfs0w6M61suohRzP6HM= sha1:JOtTcw5+26R3bTNDdlY9EgvzTvw= Original-Xref: usenet.stanford.edu gnu.emacs.help:213941 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:106226 Archived-At: On Sat, 01 Aug 2015 18:49:38 -0400 Stefan Monnier wrote: SM> - plists need to be "parsed" in order to figure out if an element is a key SM> or a value. That's true, but there's some idea that a plist is "correct" if it can be parsed. It's also visually easier to parse, I think, especially for beginners. Also, symbol plists are pretty well ensconced at the C level. By contrast, alists don't have a strong structure and parsing them is not simple for beginners. For instance: (alist-get 'a '((a) (b 1) (c . 2) d)) -> nil (alist-get 'b '((a) (b 1) (c . 2) d)) -> (1) (alist-get 'c '((a) (b 1) (c . 2) d)) -> 2 (alist-get 'd '((a) (b 1) (c . 2) d)) -> nil ; no error The real map type in Emacs Lisp is the hashtable, I think. But because of historical baggage, we end up discussing the benefits of two list formats when used as maps. Which feels like discussing which of two different bicycles is better for carrying 5 people. For instance, the hashtable keys are unambiguously (hash-table-keys my-hashtable) and there's no looping or parsing. I wonder, if hashtables had a better reader syntax (like plists or alists) and better Customize support, would they see wider use? Or is the historical baggage in tutorials and existing code too much at this point? Ted