by chubot · 3y ago · 0 comments
Looks like it broke earlier this year, but the rest of his site is still up.
It's very weird that there's already a "canonical" format for s-expressions, and then Racket apparently implemented something incompatible -- BUT WITH THE SAME NAME.
They are both called "csexp".
---
Rivest's draft is filled with a lot of words, but this looks like a clear incompatibility:
A verbatim encoding of an octet string consists of four parts:
-- the length (number of octets) of the octet-string, given in decimal most significant digit first, with no leading zeros.
-- a colon ":"
-- the octet string itself, verbatim.
That's a length prefix. Also, unless my head is exploding, that's 3 parts, not 4.
In contrast, the Racket library uses a length suffix:
Spaces are removed and all strings are suffixed by their size and a colon : separator.
That's super weird. This is really "the curse of Lisp" ...
---
Of course maybe nobody actually uses Rivest's thing. But the length PREFIX is conventional so you know how much to allocate (netstrings, bencode, etc.)
Not sure why they would go with a length suffix -- I've never heard of that.
I could see making it incompatible to improve it, but it doesn't seem improved.
The OP link is not part of the Racket language or its standard library. It is simply the documentation for a package written by a member of the community and hosted on Racket's official package platform — like putting something on PyPI if you're familiar with the Python ecosystem.
The package itself is listed over here [0], which links us to the source code [1], which in turn attempts to link to a URL that suggests the idea is due to Rivest [2], but that URL has apparently died.
[0] https://pkgs.racket-lang.org/package/csexp
With netstrings, it's
3:bag,
with a comma, which makes it a bit more readable over the wire.The extra level of Racket quoting was confusing me -- #"" and \" -- it would be nicer if they just wrote exactly what's transmitted over the wire.
And still the page does seem like it's missing a reference. Both Rivest's page and this page seem a bit underdeveloped for a "canonical" format ...
Namely interoperability between Lisps