ietf
[Top] [All Lists]

Re: Last Call: <draft-bormann-cbor-04.txt> (Concise Binary Object Representation (CBOR)) to Proposed Standard

2013-08-19 04:09:03
Paul Hoffman <paul(_dot_)hoffman(_at_)vpnc(_dot_)org> wrote:
On Aug 15, 2013, at 3:11 PM, Yaron Sheffer 
<yaronf(_dot_)ietf(_at_)gmail(_dot_)com>
wrote:

- A parser that looks for duplicates must be able to detect that
{{"a":1, "b":2}:4, {"b":2, "a":1}:5} does in fact have a duplicate
key, because the two internal maps (used as keys) are identical. So in
general, parsers need to canonicalize maps to any depth in order to
detect duplicates. This is "complex" by any definition of the word.

It does not need to canonicalize, but it does need to reify (or some
word that means "know what each name means"). This is not additional
code: the decoder already has that in the semantic processor. It is only
additional runtime during decoding, and only in protocols/applications
that use maps as keys.

We could say "you cannot use maps as keys in maps because it is too
hard", but then the question is where do we draw the line on "too hard".
Is it "too hard" to use arrays? They might be arrays with arrays in
them; is that too hard? Instead of the CBOR spec saying "this is too
hard for you to do", we at some point have to trust the
protocol/application developer to understand the tradeoffs.

YAML allows map keys to be arbitrary data structures. It requires keys to
be unique and uses structural equality to determine uniqueness, which
leads to the interesting difficulty that Yaron Sheffer pointed out.

Lua allows table keys to be arbitrary data structures. It requires keys to
be unique, but keys that are composite data structures are compared by
reference: each table literal is a new table.

You can express Lua-style data structures in YAML by giving unique tags to
each part of the data structure. You can express sharing in Lua by
assigning a part of the structure to a variable which is later used to
refer to that part.

I think CBOR should be clear about how it handles sharing and equality.

Tony.
-- 
f.anthony.n.finch  <dot(_at_)dotat(_dot_)at>  http://dotat.at/
Forties, Cromarty: East, veering southeast, 4 or 5, occasionally 6 at first.
Rough, becoming slight or moderate. Showers, rain at first. Moderate or good,
occasionally poor at first.

<Prev in Thread] Current Thread [Next in Thread>