kdl icon indicating copy to clipboard operation
kdl copied to clipboard

KDL Spec: properties as a key-value store

Open Lucretiel opened this issue 3 years ago • 6 comments

Currently, in the KDL spec, it doesn't appear to be possible to use properties as a key-value store (ie, comparable to a HashMap<String, Value>, because min and max aren't available properties for them. If this is intentional, let me know, and I'll update the roadmap for kaydle, as this was intended to be one of the patterns I support.

Lucretiel avatar Sep 01 '21 00:09 Lucretiel

huh? I'm confused. What do you mean? Are you talking about the Schema spec?

zkat avatar Sep 01 '21 01:09 zkat

Yeah so I'm talking about, given this type:

struct Document {
    values: HashMap<String, i32>
}

It ~is~ will be possible to deserialize from this document:

values x=1 y=2 z=3

I wasn't seeing a way that this could be encoded into the spec, because I didn't see a way to express that you could have a variable number of properties.

Lucretiel avatar Sep 01 '21 01:09 Lucretiel

I did just notice that property::key is optional, which if absent presumably means it can have an unlimited number of properties? I was looking for min and max; their absence is why I assumed properties were not variadic

Lucretiel avatar Sep 01 '21 01:09 Lucretiel

prop > key being omitted means that the rules for that prop apply to all properties for this node.

props also have no min or max because only one of each property key is allowed.

zkat avatar Sep 01 '21 01:09 zkat

Oh it's possible I misunderstood something then. If you have an unkeyed node with a min and max, that's not constraining the total number of nodes, that's constraining the total number of each particular node key separately?

Lucretiel avatar Sep 01 '21 01:09 Lucretiel

Can you show me an example of what you mean? The schema is a bit brain-twisty and I wouldn't be surprised if I just brain farted while writing some bit and wrote it in a way I don't intend?

zkat avatar Sep 01 '21 01:09 zkat