Hacker News new | ask | show | jobs
by amiga386 686 days ago
Canonical S-expressions seem remarkably similar to bencoding as used in BitTorrent files. They both use length prefixes written in ASCII digits followed by a colon.

    Canonical S-Expression: (9:groceries(4:milk5:bread))
    Bencoding:              l9:groceriesl4:milk5:breadee
Bencoding also manages to specify dictionaries, and yet still have a canonical encoding, by requiring dictionaries be sorted by key (and keys be unique).

It doesn't have the option for arbitrary type names, it just has actual types: integer, bytestring, list and dictionary.

FTA:

> Bencoding offers many of the same benefits of CSEXP, but because it also supports types, is a bit easier to work with.

Hmm, well there you go.

1 comments

How would you encode a bencode where the list doesn’t end in a list ? Or is that the purpose of the letter ‘e’ ?