On 2019-09-16 18:49, Lassi Kortela wrote: >> Might I interest you in a simple "binary S-expressions" format that >> can be converted into textual S-expressions and back? I've been >> wanting to make one for a long time and this would be a perfect >> application :) >> >> Using varints for all numerical quantities, and encoding all strings >> with a varint length prefix, one gets trivial code with no endianness, >> escaping or whitespace issues and no size limits. Embedding binary >> blobs is trivial. A varint type tag can distinguish between different >> kinds of objects. There are ways to wring more bit density out of all >> this stuff but I would favor simplicity. > > I hacked this up: > <https://github.com/lassik/scheme-database-temp/blob/master/binary.sls> > > 80 lines of Scheme. The "test-binary" program in the same repo shows > that the library can write its own source code as a binary > S-expression and read back equal results :) > > TODO: numbers other than integers Hello, I have written a similar thing. Dotted Canonical S-expressions You can read about it here: https://gist.github.com/rain-1/a253e47b939fc0769524d8716541c96e the summary is that it's a compact representation of s-exps which supports nesting without escaping.