Skip to content
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] A declarator does not have an initializer. #1616

Merged
merged 1 commit into from Nov 12, 2017

Conversation

jensmaurer
Copy link
Member

Fixes #1615.

@@ -2388,11 +2388,11 @@
\indextext{initialization|(}

\pnum
A declarator can specify an initial value for the
An \grammarterm{init-declarator} can specify an initial value for the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to switch from the English term to the grammar term here, I think we should use "init-declarator or member-declarator". We would also need to do something about conditions, which don't explicitly say that the variable is initialized from its brace-or-equal-initializer.

Maybe it would be better to say something like:

A declarator can be followed by an initializer that specifies an initial value for the entity being declared. [Note: In some contexts, only the brace-or-equal-initializer form of initializer is permitted by the grammar, but these rules still apply.]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. It might also be better to put some distance between the initialization rules, which generally have an initializer and some target entity, and the special case of initializing in a declaration. Perhaps this paragraph should start by talking about initialization in general, and then say that one of the places this happens is when a declarator is followed by an initializer (and other places include initialization of function parameters from arguments and initialization of return values).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. [dcl.init] started out at explaining the syntax for initialization, and is only ever so slowly morphing into a general description of all kinds of initialization, where the invoking syntax is secondary. The introductory paragraph follows that anti-pattern quite nicely.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A declarator can be followed by an initializer that specifies an initial value for the entity being declared.

This is description is correct, however I think we should emphasize on the 'initializer' which is the topic of this section [dcl.init]

If we look at the introductory description of [dcl.decl] p1

The init-declarator-list appearing in a declaration is a comma-separated sequence of
declarators, each of which can have an initializer.

It is easy to understand [dcl.init] was intended for "initializer".

@jensmaurer
Copy link
Member Author

Here's a larger rewrite that moves into the "all initializations are equal" direction.

@tkoeppe
Copy link
Contributor

tkoeppe commented Aug 1, 2017

@jensmaurer: Please rebase. (In fact, please rebase all your pending PRs.)

@jensmaurer
Copy link
Member Author

Rebased.

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.

None yet

4 participants