phiryll / lexy

Lexicographical Byte Order Encodings
MIT License
0 stars 0 forks source link

Allow delimiters to be optional if elements are implicitly delimited #28

Open phiryll opened 1 week ago

phiryll commented 1 week ago

Types that must be explicitly delimited:

Note that these types cannot be implicitly delimited, because they have variable size. These are unlike big.Int and big.Float, which are normalized in a way that allows the length prefix itself to be significant in the sort order.

Different ways to do this:

  1. All types that might require explicit delimiters do require them. Structs are the only type where this would be in question.
  2. Codec has another method returning whether it requires one.
  3. Codecs that require explicit delimiters always add one at the end, and therefore escape their contents. However, this is wasteful if these types are never part of an aggregate (string db keys, e.g.).
phiryll commented 1 week ago

I realized after creating this issue that all aggregates must escape and delimit their elements, because there's no way to tell whether a pointer-to-interface element would require one.

The only exception would be aggregates with clearly fixed size elements. This can be a later optimization.