Replies: 2 comments 2 replies
-
for tools (formatters, templating, etc.), you're going to need more than just comments in order to do a round trip:
And, the common case would be programs using KDL as a config file and such, which don't need to know about comments (and maybe shouldn't, to discourage putting data in comments?) but also all of this is kinda necessary for tooling. i'm not sure if that means a second parser, or feature flags, or a function to convert to the simpler format. probably depends on the implementation language? |
Beta Was this translation helpful? Give feedback.
-
This is definitely an implementation concern, imo. For example, a serde-based parser might not want to deal with comments at all, since it only cares about data coming in, and would have some default way of dealing with data going out. What you're talking about is what I've heard called a "document-oriented parser", which would retain comment, spacing, and input format. I don't know if there's anything to do to allow this at the specification level, although I already made some decisions that require this type of parser for proper round-tripping for sure. But unless you're something as simple as JSON, this will usually be the case. |
Beta Was this translation helpful? Give feedback.
-
This is perhaps more aimed at implementations than the spec, but I think it would be really beneficial to have first-class support for comments in the APIs rather than them being silently discarded.
The main use would be when generating kdl strings from a program:
This raises questions:
Regarding comments in general, there's currently no concept of attaching comments to nodes, comments are just free. E.g. semantically or structurally, should there be a difference between these two below:
Beta Was this translation helpful? Give feedback.
All reactions