Replies: 8 comments 9 replies
-
Sounds reasonable to me. It's easy to configure most text editors to always ensure a trailing newline, I think. (At least, Sublime is easy.) |
Beta Was this translation helpful? Give feedback.
-
Personal preference: I can't stand files that don't end in a newline. Makes me feel claustrophobic or something. I like the idea of an explicit terminator, but I don't know how I feel about it being required. In syntaxes like JSON and XML, final terminators are "obvious" because they're part of the the natural flow language. With kdl, I feel like an explicit terminator combats directly with the direct design. Like you said in the readme, kdl "looks like you're invoking a bunch of CLI commands". An explicit terminator seems to be out of place with that. I think it'd be a little 'foot-shotgunny' to require it. What might be a good compromise would perhaps be a "warning" of sorts — the parser would parse everything it can and return it to the user, but with a notice/flag that says "this document was not explicitly terminated". That way, the users who don't care can just continue as is, but those who expect explicit termination would know to reject (or distrust) the results. I do like the idea of an optional "this is the end of this config", similarly to how yaml uses I feel like I've done nothing in my opinion here but further complicate things. 🙃 |
Beta Was this translation helpful? Give feedback.
-
I’m not strongly opposed to this idea, but I’m not sure what we gain from it. Accidentally truncating a document isn’t AFAIK much of an issue. It was more of an issue with HTTP/0.9 responses where truncated documents couldn’t be detected, but that’s not really a concern for KDL. If we do go ahead with this we should just require a trailing newline rather than using |
Beta Was this translation helpful? Give feedback.
-
my only thought is that if you require it, then someone will eventually make a variant which does not |
Beta Was this translation helpful? Give feedback.
-
I don't think it's reasonable to assume most editors are going to do the right thing in terms of trailing newlines here. I'm sure Sublime Text or VS Code will, but Notepad, TextEdit, nano... might not. Maybe I've misread the target audience here but it would be a very obtuse error for someone who's not too tech-savvy just trying to Make Something Work. Enforcing a trailing visible token makes sense though, IMO. Whether that's a closing brace, semicolon, or something else. |
Beta Was this translation helpful? Give feedback.
-
Isn't is true that accidentally truncated files will mostly fail to parse regardless of whether there is a ; or newline in the end? For example an unclosed string is an error anyway. I see how without explicit EOF in some cases it will accidentally succeed to parse (when we don't want it to), for example
So maybe explicit EOF is a good idea.
Then the document parses OK as if it has a trailing newline but is actually truncated so our EOF requirement didn't help us. I guess that's why |
Beta Was this translation helpful? Give feedback.
-
@Lucretiel found it! ^ |
Beta Was this translation helpful? Give feedback.
-
I've converted this into an issue so we can make sure to resolve this by 1.0.0: #116 |
Beta Was this translation helpful? Give feedback.
-
I think we should make it a requirement to have either a newline or a ; as the last character in a document. This means that accidentally truncated files will simply fail to parse.
on the flip side, it means that folks who don't put a final newline in their files still get obnoxious errors, which kinda sucks but I assume most editors will help people do the right thing here?
Beta Was this translation helpful? Give feedback.
All reactions