From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: User-defined record types Date: Sat, 19 Oct 2013 10:37:48 -0400 Message-ID: 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> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1382193485 27741 80.91.229.3 (19 Oct 2013 14:38:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 19 Oct 2013 14:38:05 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Oct 19 16:38:08 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 1VXXfK-0006jf-V1 for ged-emacs-devel@m.gmane.org; Sat, 19 Oct 2013 16:38:07 +0200 Original-Received: from localhost ([::1]:33477 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VXXfK-0003Ga-DZ for ged-emacs-devel@m.gmane.org; Sat, 19 Oct 2013 10:38:06 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58141) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VXXfB-0003GU-4s for emacs-devel@gnu.org; Sat, 19 Oct 2013 10:38:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VXXf3-0006Xt-Ki for emacs-devel@gnu.org; Sat, 19 Oct 2013 10:37:57 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:56908) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VXXf3-0006Xe-Gv for emacs-devel@gnu.org; Sat, 19 Oct 2013 10:37:49 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFFLd/LJ/2dsb2JhbABEvw4Xc4IeAQEEAVYoCws0EhQYDYhCBsEtjSU8gykDpHqBXoMTgUs X-IPAS-Result: Av4EABK/CFFLd/LJ/2dsb2JhbABEvw4Xc4IeAQEEAVYoCws0EhQYDYhCBsEtjSU8gykDpHqBXoMTgUs X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="35876461" Original-Received: from 75-119-242-201.dsl.teksavvy.com (HELO pastel.home) ([75.119.242.201]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 19 Oct 2013 10:37:48 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 469F9616AC; Sat, 19 Oct 2013 10:37:48 -0400 (EDT) In-Reply-To: <87sivxmqgk.fsf@flea.lifelogs.com> (Ted Zlatanov's message of "Sat, 19 Oct 2013 07:48:27 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.182 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:164360 Archived-At: SM> You lost me: I though "null" and "empty list" were JSON thingies, so SM> I just offered you ways to represent them on the Elisp side. Of course, SM> when turning those elements into JSON, you'd be careful to map them to SM> the appropriate JSON elements. > Right. So instead of a special mapping operation, the underlying C > storage (record) should hold the JSON/YAML/XML types and values > directly. Huh... no, I'm thinking about json.el, with no C code involved at all. SM> I still don't understand in what way a custom data structure would help. > By holding the original data in a way that today's Emacs internals can't. For example? > - 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'). Let's call [[e]] the Elisp representation of JSON's e. Then you're saying that [[null]] would be exposed as nil and [[false]] as well? Then would it be the case that (eq [[false]] [[null]])? I really don't see how you expect to turn those into `nil', preserve sane semantics (and Elisp performance), and be able to recover null, [], and false when converting them back to JSON. You can probably pick any two of the three, but all three together sounds pretty much impossible. > - stored efficiently Saying so is not sufficient to make it so. > format. The C implementation would also be more efficient than an ELisp > implementation if it serializes to and from JSON in C, but that's a > minor concern. We're back at the FFI discussion, which is a different issue. > 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. C is not magic. Such a "feature" would require changes deep in the elisp/bytecode interpreter, the NILP function/macro, ... Stefan