unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ted Zlatanov <tzz@lifelogs.com>
To: emacs-devel@gnu.org
Subject: Re: mapping data formats imported from C libraries
Date: Wed, 26 Nov 2014 07:59:04 -0500	[thread overview]
Message-ID: <87r3wqazjb.fsf@lifelogs.com> (raw)
In-Reply-To: m3k32j6wgy.fsf@stories.gnus.org

On Tue, 25 Nov 2014 18:06:37 +0100 Lars Magne Ingebrigtsen <larsi@gnus.org> wrote: 

LMI> Ted Zlatanov <tzz@lifelogs.com> writes:
>> Yes, but in a really sucky way. If you look at the libjson and json.el
>> output, it's much leaner. Mapping JSON up to XML pretty much guarantees
>> pain when you use it and on the way back.  Do you want to inflict that
>> on everyone in the name of a unified DOM?

LMI> The Emacs DOM is quite non-sucky.  It's just a tree.

LMI> (thing ((attrib . value)) (foo) (bar))

LMI> JSON maps onto it really nicely.  The attributes are always nil, though.

Yeah, I've seen the mess that libxml2 and json.el produce (not the
coder's fault, it's just a pain to adapt without native types).  It
doesn't help that XML/SGML and Lisp are inbred cousins :)

* it's a pain to distinguish JSON's `false' and `null' while using them
  in code

* in json.el you pick the key-value storage method! yay!

* in json.el you pick the array storage method! yay!

* JSON data is not a tree

My ideal mapping from libjson and libyaml would be:

* unambiguous: you can reconstruct a canonical version of the input
  stream from the parse data, as much as possible (JSON is better at this)

* native: you can iterate over JSON arrays as Lisp lists, and JSON
  key-value mappings as alists.  JSON's `false' and `null' are both
  false in Lisp boolean context.

* clean: no extra cons cells for attributes

* readable: this is huge IMO, to be able to pretty-print the data and
  quickly see what it contains... one of the things I like about JSON
  vs. SGML/XML.

The ideal thing may be a "libjson/libyaml native" data format that can
then be bidirectionally mapped to the DOM you suggest...

Ted




  parent reply	other threads:[~2014-11-26 12:59 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-23 15:18 DOM manipulation functions Lars Magne Ingebrigtsen
2014-11-23 15:58 ` joakim
2014-11-23 15:59 ` Rüdiger Sonderfeld
2014-11-23 16:01   ` Lars Magne Ingebrigtsen
2014-11-23 16:52     ` Steinar Bang
2014-11-24  0:26   ` Leo Liu
2014-11-25  9:12     ` mapping data formats imported from C libraries (was: DOM manipulation functions) Ted Zlatanov
2014-11-25 15:54       ` mapping data formats imported from C libraries Lars Magne Ingebrigtsen
2014-11-25 16:27         ` Ted Zlatanov
2014-11-25 16:32           ` Lars Magne Ingebrigtsen
2014-11-25 16:40             ` Ted Zlatanov
2014-11-25 17:06               ` Lars Magne Ingebrigtsen
2014-11-26 10:41                 ` Steinar Bang
2014-11-26 15:51                   ` Lars Magne Ingebrigtsen
2014-11-26 19:57                     ` Steinar Bang
2014-11-26 20:00                       ` Lars Magne Ingebrigtsen
2014-11-26 12:59                 ` Ted Zlatanov [this message]
2014-11-26 15:56                   ` Lars Magne Ingebrigtsen
2014-11-26 16:48                     ` Ted Zlatanov
2014-11-23 18:45 ` DOM manipulation functions raman
2014-11-25 11:01 ` Nicolas Richard
2014-11-26 18:44 ` Lars Magne Ingebrigtsen
2014-11-26 19:42   ` Ted Zlatanov
2014-11-26 19:44     ` Lars Magne Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r3wqazjb.fsf@lifelogs.com \
    --to=tzz@lifelogs.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).