Skip to content

[dcl.init.string] Reword character array initialization #6488

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Eisenwave
Copy link
Member

@Eisenwave Eisenwave commented Aug 21, 2023

image

This edit greatly compactifies the current wording. The issue with the status quo is that it contains a massive clause of:

X, Y, Z, or W may be initialized by A, B, C, or D respectively

Such a clause is difficult for the reader to follow, and it's easy to make a mistake when matching B to Y 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

X is initialized by a string-literal of type X

Some care is required due to the string-literals being arrays of const characters.

Furthermore, the wording of

or by an appropriately-typed string-literal enclosed in braces

is quite verbose, and could be simplified to "optionally brace-enclosed". This is just as clear, but much more concise.

Copy link
Contributor

@JohelEGP JohelEGP left a 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.

@Eisenwave Eisenwave force-pushed the reword-character-array-init branch from bf13ef6 to ef5b3db Compare August 21, 2023 09:58
@Eisenwave
Copy link
Member Author

Eisenwave commented Aug 21, 2023

image

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.

@Eisenwave Eisenwave force-pushed the reword-character-array-init branch from ef5b3db to 0bb4a1e Compare August 21, 2023 10:00
@jensmaurer
Copy link
Member

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.

@Eisenwave

This comment was marked as outdated.

@Eisenwave

This comment was marked as outdated.

nest const in tcode

Co-authored-by: Johel Ernesto Guerrero Peña <johelegp@gmail.com>

fix stray 'a'

Co-authored-by: Johel Ernesto Guerrero Peña <johelegp@gmail.com>

fix semantic changes

itemize instead
@Eisenwave Eisenwave force-pushed the reword-character-array-init branch from 0bb4a1e to c2a3389 Compare August 21, 2023 19:46
@Eisenwave
Copy link
Member Author

image

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants