Replies: 3 comments 9 replies
-
at least one implementation seems to have already implemented this
|
Beta Was this translation helpful? Give feedback.
-
Kuddle supports property annotations (even in v1, which was a side effect of using the same Value struct for keys and values) defmodule Kuddle.Node do
alias Kuddle.Value
defstruct [
name: nil,
annotations: [],
attributes: [],
children: nil,
]
@typedoc """
An attribute is either a property `{key, value}`, or just a plain value.
"""
@type attribute :: {key::Value.t(), value::Value.t()} | Value.t()
@type t :: %__MODULE__{
name: String.t(),
annotations: [String.t()],
attributes: [attribute()],
children: [t()] | nil
}
end
defmodule Kuddle.Value do
defstruct [
value: nil,
annotations: [],
type: :id,
format: :plain,
]
end
I'd agree, allowing annotations on property keys should be fine, I can't think of a reason why it shouldn't be allowed. |
Beta Was this translation helpful? Give feedback.
-
I've got no particular problem with annotations on keys (they're trivial to parse, tho they do present some data-model complexities), but I do question their value. Key annotations would be similar to node annotations, rather than value annotations - they'll provide some additional context to the node/key, rather than telling you what kind of data is in the value. This is useful for nodes, because you can have multiple nodes with the same node name in a single child list, which are meant to provide different things (say, an But key names have to be unique on a node already, so all necessary context is already baked in to their name. And the property's value can carry its own annotation when necessary. So what is an actual use-case for a property key annotation? |
Beta Was this translation helpful? Give feedback.
-
Allow annotating properties in the same way that values and identifiers can be annotated.
Beta Was this translation helpful? Give feedback.
All reactions