From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.devel Subject: Re: hash-table-{to, from}-alist Date: Fri, 21 Nov 2008 16:22:59 -0600 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <86ej14vhvg.fsf@lifelogs.com> References: <34f9604c-a23b-4ad9-9c84-f45884a6df23@x16g2000prn.googlegroups.com> <86od3dfd86.fsf@lifelogs.com> <868wuflxv9.fsf@lifelogs.com> <863aknitfg.fsf@lifelogs.com> <20080830051807.GB9625@tomas> <86bpwe9su5.fsf@lifelogs.com> <867i6z1jo5.fsf_-_@lifelogs.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1227306279 29059 80.91.229.12 (21 Nov 2008 22:24:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 21 Nov 2008 22:24:39 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Nov 21 23:25:41 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1L3eRX-0001tT-MU for ged-emacs-devel@m.gmane.org; Fri, 21 Nov 2008 23:25:40 +0100 Original-Received: from localhost ([127.0.0.1]:50161 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L3eQO-0001D6-OE for ged-emacs-devel@m.gmane.org; Fri, 21 Nov 2008 17:24:28 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L3ePd-0000Y5-Dk for emacs-devel@gnu.org; Fri, 21 Nov 2008 17:23:41 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L3eP8-0000Fx-BC for emacs-devel@gnu.org; Fri, 21 Nov 2008 17:23:40 -0500 Original-Received: from [199.232.76.173] (port=50795 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L3eP8-0000Fp-8t for emacs-devel@gnu.org; Fri, 21 Nov 2008 17:23:10 -0500 Original-Received: from main.gmane.org ([80.91.229.2]:54538 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L3eP8-0000YL-3H for emacs-devel@gnu.org; Fri, 21 Nov 2008 17:23:10 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1L3eP4-0002oH-Qv for emacs-devel@gnu.org; Fri, 21 Nov 2008 22:23:06 +0000 Original-Received: from 38.98.147.130 ([38.98.147.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 21 Nov 2008 22:23:06 +0000 Original-Received: from tzz by 38.98.147.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 21 Nov 2008 22:23:06 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 42 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 38.98.147.130 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" User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:wuFpKRYOlQbneRiteTpdu1a7p5I= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:105914 Archived-At: On Fri, 21 Nov 2008 17:02:06 -0500 Stefan Monnier wrote: TZ> I propose the following functions (originals were contributed to Gnus by TZ> Andreas Fuchs ): TZ> (defun hash-table-to-alist (hash) TZ> (defun hash-table-from-alist (alist &rest options) >> If there are no objections or comments, I'll commit my version tomorrow >> with a manual update to follow once the functions are stable. Where >> should this go under the lisp/ directory? SM> They don't look too harmful, but I think we need more: we need to hook SM> this into prin1 and into read so it works transparently. We can't, because we're converting to an alist and there's no way to convert back. True serialization would require a new marker, similar to () for lists and [] for vectors. Braces would probably work, I don't think they are used anywhere: { :prop1 prop-value1 :prop2 prop-value2 ... key1 val1 key2 val2 ... } (:prop1 is :test for example) WDYT? It would cause read errors to have an odd number of elements, but otherwise it's pretty clean. The properties are the same as those you can pass to make-hash-table, and are always serialized (but not required on read). You can have keys named :test for example, because the :test property happens first and then any subsequent :test keys are assumed to be hash keys. Incidentally, the docs for prin1 should probably have examples for the output of a vector and a series of simple examples of the other data types, or a link to somewhere those are shown. I didn't find it in the manual. SM> So all this looks pretty "post 23.1" to me. OK. If we agree on the format I can produce a patch for eventual inclusion. Ted