[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Look for data serialisation format to implement communication betwee
Re: Look for data serialisation format to implement communication between Emacs and external program.
Mon, 07 Jan 2013 15:35:01 +0200
Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)
On 2013-01-07, Thien-Thi Nguyen wrote:
> () Oleksandr Gavenko <address@hidden>
> () Sun, 06 Jan 2013 23:44:46 +0200
> Another formats like JSON or sexp also look nice but I don't know
> about Emacs support for this formats.
> Go with sexp. If you must touch XML, at least dress it up as SXML,
> which, aside from being less ugly, extends interop to include Scheme.
> E.g., sexp + SXML is the approach IXIN uses. Latest announcement:
One thing stop me from using sexp - my Python code can be possible used in
another cases where sexp parser can be absent.
> If you absolutely need a binary (non-text) format, then i would next
> recommend bindat.el (info "(elisp) Byte Packing") for the job. Perhaps
> ASN.1 can be layered on top of bindat.el, but that doesn't sound so fun.
> (But what do i know about ASN.1 and/or fun?)
Thank for suggestion. I completed simple type-length-value example:
(setq bin-str (unibyte-string ?s 4 ?h ?a ?l ?o))
(setq bin-header '((:type u8) (:len u8) (:val vec (:len))))
(setq bin-data (bindat-unpack bin-header bin-str))
(bindat-pack bin-header bin-data)
But as input come from external process I need manually check for input end
because parsing of incomplete input take error "args-out-of-range".
I don't know how to resolve this issue.
I expect to find a way to get data validation for free (like XSD/RNC for XML).
Also I don't see have can I split data into packets with "bindat" (Emacs send
request and Python send response in a loop without dropping connection while
returned data is valid). As solution - make 10 attempt with 1 sec delay and
then report error - incomplete or invalid packet...
> Lastly, on the other side of the pipe, why not consider Emacs itself, or
> Guile, or something that can ‘read’ a sexp?