-
Notifications
You must be signed in to change notification settings - Fork 751
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
[dcl.init.string] Reword character array initialization #6488
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an editorial review.
bf13ef6
to
ef5b3db
Compare
I was overthinking it. After the most recent changes, the more complicated rules weren't even much less verbose, so I've decided to dumb it down and make a list instead. This feels so much better. One noteworthy issue that the first and third bullet have to be assumed to be additive rules by the reader. If the reader assumes that the bullets are mutually exclusive, and I don't think they reasonably should, then this list of items is contradictory. |
ef5b3db
to
0bb4a1e
Compare
The current state is, once more, a situation where we put bullets in front of sentences without them being conditions or similar. They aren't even mutually exclusive. I'm not convinced this is an improvement. I did think, however, that the intermediate state that got rid of repeating all the types was a mild improvement, avoiding repetition. We won't get rid of the special case regardless. |
They could be made made a conjunction if they were combined with
I think it was a mild improvement too, but still needlessly complex. Ideally, the reader should be able to tell at first glance which array belongs to what literal. Something like a list of bullets or a table is ideal. Also, I think they can be made mutually exclusive if they are phrased in terms of which literal can be used to initialize what array, i.e.:
@jensmaurer What do you think about that? Now bullets are mutually exclusive, and a conjunction.
Not entirely, but now that special case is contained in the bullet for UTF-8 string literals, and doesn't break mutual exclusion. |
We can also formally define what it means for a string literal to be appropriately typed for the initialization of an array, and that would be a disjunction with three bullets. That term is used colloquially throughout the standard anyway. Then, say that an array may be initialized by an appropriately typed string literal. This would actually shorten wording in other places too. Idea
This covers everything very compactly, and is very implementer-friendly because it's close to how you would check for validity in a compiler. |
nest const in tcode Co-authored-by: Johel Ernesto Guerrero Peña <[email protected]> fix stray 'a' Co-authored-by: Johel Ernesto Guerrero Peña <[email protected]> fix semantic changes itemize instead
0bb4a1e
to
c2a3389
Compare
I think @jensmaurer was on the right track. The intermediate version had potential, and if we just drop the use of the defined terms for string literals and focus on the types, everything can be elegantly described in three concise, disjunctive bullets. |
This edit greatly compactifies the current wording. The issue with the status quo is that it contains a massive clause of:
Such a clause is difficult for the reader to follow, and it's easy to make a mistake when matching
B
toY
etc. What the paragraph is saying, in essence, is that an array may be initialized by a string literal of the same type. These types are clearly defined in [lex.string.literal], and could be used in this paragraph.We can simply say that
Some care is required due to the string-literals being arrays of
const
characters.Furthermore, the wording of
is quite verbose, and could be simplified to "optionally brace-enclosed". This is just as clear, but much more concise.