Magic Characters #143
-
Sometimes serialization formats share the wire. When this happens, it's useful to be able to tell from reading the first couple characters that the content should be routed to parser X. For example, "<" is a sign that we're in the XML family, "(" that we're looking at s-exp, "{" would be JSON, "%" YAML, etc. I would like to suggest that starting KDL documents with a node comment, "/-" (perhaps with some convention regarding metadata, such as version) would be a good best practice and perhaps a reasonable protocol recommendation |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I mean... your examples don't even work for the languages specified?
As such, I'm not sure there's much we can do here on the KDL side to facilitate this use case. Perhaps the approach needs to be addressed instead? |
Beta Was this translation helpful? Give feedback.
-
My application is allowing permissive syntax choices for players developing game clients for turn-based strategy games. I'd planned a sieve-like strategy to route messages, but using OAuth2 scopes will be a more robust strategy. I didn't intend the examples to be thorough (They are sufficient for the subset of protocols supported in my environment. Well, there's a second entry for YAML and I'm processing JSON with a YAML reader, but that is what it is.); I didn't see the specifics of the implementation as relevant to the suggestion I'd still recommend something of the nature /- kdl version="1.0.0" generator="vim" author="Chris" (syntax?) as a best practice for debugging purposes. This is less important if the spec has low churn, but It's something that I want for my environment. It's fine if it's not something that you want for general use, but I want to float that idea before the conversation is closed Also, I'm aware that "This is a place to store metadata..." isn't supported by the emphasis of my original post. I didn't really think that through to the point of changing the title, and perhaps I should have If you'd prefer to have metadata like version be actionable without human intervention, then a kdl node with a version property that isn't commented would be better semantics. Beginning the document with this node could be useful, though I do see that making the order of nodes relevant is against the design philosophy. To be clear, I'm not trying to change that philosophy. "That's off scope for this project," is as reasonable as "This is is how we'd accomplish that goal idiomatically." Either way, I can write a style guide for my projects with a reasonable expectation that it is likely to be forward compatible with future versions |
Beta Was this translation helpful? Give feedback.
I mean... your examples don't even work for the languages specified?
{
could be Dhall (comments) or JSON5, among others, for example.%
.{
. There's no requirement that the toplevel be an object. It could be an array! Or any other type.<
could be html5As such, I'm not sure there's much we can do here on the KDL side to facilitate this use case. Perhaps the approach needs to be addressed instead?