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: User-defined record types Date: Sat, 19 Oct 2013 16:11:41 -0400 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <87k3h9m35u.fsf@flea.lifelogs.com> References: <85k3hlcqvm.fsf@junk.nocrew.org> <8561t5cclt.fsf@junk.nocrew.org> <85mwmgbb4l.fsf@junk.nocrew.org> <85vc12a36o.fsf_-_@junk.nocrew.org> <87a9i6ofzg.fsf@flea.lifelogs.com> <87wqlamacc.fsf@flea.lifelogs.com> <87sivxmqgk.fsf@flea.lifelogs.com> Reply-To: emacs-devel@gnu.org NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1382213506 11680 80.91.229.3 (19 Oct 2013 20:11:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 19 Oct 2013 20:11:46 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Oct 19 22:11:49 2013 Return-path: Envelope-to: ged-emacs-devel@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 1VXcsG-0008Uo-Qc for ged-emacs-devel@m.gmane.org; Sat, 19 Oct 2013 22:11:49 +0200 Original-Received: from localhost ([::1]:34267 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VXcsG-0003d4-9e for ged-emacs-devel@m.gmane.org; Sat, 19 Oct 2013 16:11:48 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47123) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VXcs8-0003cy-KV for emacs-devel@gnu.org; Sat, 19 Oct 2013 16:11:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VXcs2-0000z1-OJ for emacs-devel@gnu.org; Sat, 19 Oct 2013 16:11:40 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:46270) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VXcs2-0000yx-HJ for emacs-devel@gnu.org; Sat, 19 Oct 2013 16:11:34 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VXcs0-0008Jk-Sc for emacs-devel@gnu.org; Sat, 19 Oct 2013 22:11:32 +0200 Original-Received: from c-98-229-61-72.hsd1.ma.comcast.net ([98.229.61.72]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 19 Oct 2013 22:11:32 +0200 Original-Received: from tzz by c-98-229-61-72.hsd1.ma.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 19 Oct 2013 22:11:32 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-devel@gnu.org Original-Lines: 51 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: c-98-229-61-72.hsd1.ma.comcast.net 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" Mail-Copies-To: never User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:Jqpr1bLXaQR9GB0KY2ukvpC8MLQ= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:164380 Archived-At: On Sat, 19 Oct 2013 10:37:48 -0400 Stefan Monnier wrote: >> - the value under the "y" key has four distinct values that should be >> represented and serialized differently, yet provide the expected >> semantics for ELisp access ("null", "[]", and "false" would be exposed >> as `nil'). SM> Let's call [[e]] the Elisp representation of JSON's e. SM> Then you're saying that [[null]] would be exposed as nil and SM> [[false]] as well? Then would it be the case that (eq [[false]] [[null]])? I would leave that up to the creator of the user-defined record type. SM> I really don't see how you expect to turn those into `nil', preserve SM> sane semantics (and Elisp performance), and be able to recover null, [], SM> and false when converting them back to JSON. You can probably pick any SM> two of the three, but all three together sounds pretty much SM> impossible. The job of this hypothetical user-defined record type would be: - preserve the original data - provide the facilities to do value folding based on the underlying data type - transparent conversion back and forth between ELisp and the C implementation - preserve ELisp semantics as far as deemed necessary by the type's creator >> Finally, a C implementation would be able to make null, false, and [] >> look like `nil' in boolean or iteration contexts, yet preserve the >> original data. SM> C is not magic. Such a "feature" would require changes deep in the SM> elisp/bytecode interpreter, the NILP function/macro, ... I understand that. Again, you asked about exciting features that could come from user-defined record types. You didn't qualify it further as "must be implemented with no major changes" etc. So to restate things clearly, I think some facility that represents structured data such as JSON, YAML, and XML well based on some user-supplied mappings would be terrific. The current ELisp representations of those three structured data formats are pretty lousy. I think this facility would be useful in many other situations by essentially encapsulating external data and providing an API on top. Whether that's a realistic priority for anyone and whether it's interesting to the Emacs maintainers, I don't know. Ted