-
-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KDL 2.0: #-prefixed identifier-based strings (and a raw string change) #350
Comments
And because identifiers cannot start with a |
So I ran into a bit of a hitch, which is that It's possible to enable Supporting
Could be very surprising if you intended to put a space after |
I don't think we need to worry too much about that, yeah. I'm comfortable with a slash requiring you to quote the string. |
The big question, I think, is just whether we think "ident-strings" are more or less common than true/false/null, and which feels more natural to have unprefixed / awkward to have prefixed. I don't have a strong opinion here, and having (This makes me old, but it slightly harkens to Scheme with its Meanwhile, it feels slightly better imo to write
This hews closer to the original design inspiration of "look kinda like console commands" - you still have to quote strings slightly more often than you do in the console, but overall it's very similar. Using # for keywords also means we avoid the future-compat issue of node names not being allowed to be keywords - you can't currently name a node |
Never mind, I argued myself into a stronger position. It is already, in 1.0, the case that a string requires positional/contextual information to know how to interpret it. You can write Currently, 1.0 allows you to write two of those as idents, if they adhere to ident syntax: I think the most consistent and readable upgrade for 2.0 to do would be to make it generically the case that strings can be unquoted if they follow ident syntax, so This consistency applies the other way, too: in 1.0, |
So you're arguing in favor of Honestly, I think I can get on board with that, but part of me is feeling kinda queasy about making everyone prefix what are probably very common keywords. Then again, it works for Scheme, and it would absolutely, positively, and safely give us idents-are-strings across the board, and that is really high value. It also makes keywords VERY obvious. At this point, my only two hesitations against
|
what do you think? |
I do like the simplicity of :—
(Previously there was no way to recognize keywords from just the first few characters; this also solves #224.) The fallback behaviour (of
I wouldn’t worry too much about existing KDL documents when the vast majority of KDL documents are yet to be written. The bigger question is whether implementations can be updated (if major implementations remain stuck in KDL 1.0, then cross‐compatibility with that version becomes more important; this is an enduring problem with YAML 1.1 ~ 1.2 for example). |
thanks for voicing this. I'm definitely settling into As far as implementations go, it's definitely going to be a bit of time before all the implementations are up to speed with 2.0, BUT, I don't think any of the parser changes are absolutely massive, and the reality is that as far as compatibility goes, people writing KDL documents only consume those particular documents using a single tool (because it's meant as a config language, usually just the specific tool they're configuring), and not as a data-exchange format like JSON is, for which precise cross-implementation compatibility is critical, and it doesn't have YAML's extensive external tooling that also all needs to agree, where even a single config might involve multiple different tools/implementations interacting with the same doc... |
Yeah, or something that syntactically distinguishes the keywords from the rest of the ident space, so we can settle on "idents are just a way to write simple strings" as a generic language rule.
Yes, this is a big point. KDL is still a fledgeling; we don't want to rip up the foundations (we'd lose all the knowledge we've gained from 1.0), but we shouldn't be afraid of significant changes if they have a very compelling reason based on that 1.0 experience. And yeah, every change so far is very trivial, at least in my parser. Some types of generated parsers might have a little trouble with some 2.0 changes, but this change in particular won't be problematic for anyone to make, I'd bet.
Yup. While we, as the general language, can't/shouldn't make weird compat hacks like that, it is absolutely reasonable for individual tools to do so as part of an update, if they need to support KDL 1.0 files. The cases where a bool is expected, and a string containing |
@tabatkins true/false/null are actually banned identifiers, and I think we should keep that rule, tbh. Not just because of weird compatibility stuff, but because a lot of people expect |
Ah, I'd actually missed that So you're saying |
alright. I'll PR these changes soon, then. It definitely seems like the best choice of everything we've discussed, with the caveat of "#true is kinda stinky and it makes me oddly uncomfortable" lol. I'm sure folks will warm up to it pretty fast. |
Side benefit: since they're now syntactically distinct, we can go full YAML and also mint |
I don't see this in the specification. Are we saying this is an invalid document in 1.0?
|
Sorry, I was messing around in the shell and screwed up my invocation. (I'd written |
|
Right. I got myself confused, but my confusion is irrelevant here. I'm still fine with This does mean that 1.0 documents will be invalid as 2.0, and thus can't be handled as a post-processing layer (at least, not without the tool having a legacy support mode, which I very well might add to kdlpy). But I do like the ability to signal to the user that the |
closing this in favor of #339, then. |
After some thought and some discussion with folks, I think a great alternative to #339 is to instead allow for quoteless strings, but only if they're prefixed with
#
.So:
Specifically, we would make the following changes:
#
would be banned from the identifier grammar only as the first character, but allow it anywhere else in the identifier.r
prefix from raw strings, such that raw strings are just#""#
. Ther
is essentially unnecessary.The text was updated successfully, but these errors were encountered: