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.meaning] General wording cleanup #3735

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sdkrystian
Copy link
Contributor

The conventions used to specify the meaning of declarators are a little inconsistent, and the sub-clause itself has a lot of single sentence paragraphs that look messy.

For example, [dcl.meaning] has a mix of specifying the "type of the identifier" and "type of the declarator-id", [dcl.ptr], [dcl.ref] and [dcl.mptr] determine the "type of the identifier", and [dcl.array] and [dcl.fct] determine the "type of the declarator-id". The mentions of "determining the type of the identifier" have been changed to determining the type of the declarator-id, as this is a better defined term.

Further, [dcl.meaning] p3 correctly acknowledged that T can contain an attribute-specifier-seq, but in the very next paragraph it assumes that T will just be a decl-specifier-seq. [dcl.meaning] p3 is rewritten to account for that, and it additionally specified that the attribute-specifier-seq appertains to the declarator (this is also specified in [dcl.pre] p2, perhaps that mention could be removed, as it makes more sense to have it where the meaning of declarators is determined).

More stylistically, [dcl.meaning] uses codeblock when specifying a declaration of the for T D, which needlessly uses whitespace, and is inconsistent with the other sub-clauses. These were changed to use \tcode.

Lastly, the last sentence of [dcl.meaning] p6 is completely redundant, and should be just turned into a note.

source/declarations.tex Outdated Show resolved Hide resolved
source/declarations.tex Outdated Show resolved Hide resolved
Copy link
Member

@jensmaurer jensmaurer left a comment

Choose a reason for hiding this comment

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

Looks fine (and is an improvement). It would be good if the line breaks wouldn't follow a troff tradition.

Copy link
Member

@zygoloid zygoloid left a comment

Choose a reason for hiding this comment

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

I think we can clean this up quite a bit more. Suggestion follows.

\tcode{T}
determines the type
\tcode{T}.
First, the type \tcode{T} is determined.
Copy link
Member

@zygoloid zygoloid Mar 12, 2020

Choose a reason for hiding this comment

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

We have two different things we're calling T here: a decl-specifier-seq and a type. This rewrite makes it less clear that that's happening by removing the "the decl-specifier-seq T determines the type T" part. I think we should take this a bit further. How about replacing the previous paragraph ("Thus[...]") with:

Thus, a declaration of a particular declarator-id has the form attribute-specifier-seq[opt] decl-specifier-seq declarator. The optional attribute-specifier-seq appertains to the declared entity. Following is a recursive procedure for determining the type of the declared entity.

Then we only have one T, and it's a type, not a decl-specifier-seq. So we can start this second paragraph with something like:

First, a type T is determined from the decl-specifier-seq. [Example: ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps we want to talk about the type of the declarator-id or name introduced rather than the declared entity? Declarations introduce names (which denote entities), after all.

source/declarations.tex Outdated Show resolved Hide resolved
source/declarations.tex Outdated Show resolved Hide resolved
source/declarations.tex Outdated Show resolved Hide resolved
source/declarations.tex Outdated Show resolved Hide resolved
Comment on lines 2716 to 2717
and the type of the identifier in the declaration
and the type of the contained
\grammarterm{declarator-id}
in the declaration
\tcode{T}
\tcode{D1}
is ``\placeholder{derived-declarator-type-list}
\tcode{T}'',
then the type of the identifier of
then the type of the
\grammarterm{declarator-id}
in
\tcode{D}
is ``\placeholder{derived-declarator-type-list} reference to
\tcode{T}''.
Copy link
Member

Choose a reason for hiding this comment

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

A declarator of the form & attribute-specifier-seq[opt] D or && attribute-specifier-seq[opt] D determines the type of its declared entity to be the type of the entity declared by the declaration U D, where U is a type-specifier that denotes the type ''reference to T''.

(And so on for later subclauses.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zygoloid The removal of derived-declarator-type-list is definitely a good idea, however, moving the form of the declarator to be inline does degrade readability, especially for longer declarator forms (i.e. functions). Perhaps we keep the form of the declarators indented as is done currently, and apply the other changes to the paragraphs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, maintaining T throughout subclauses is a little awkward, and could lead to confusion (typically, when "variables" are established, we carry them no further than then end of a paragraph, let alone a subclause)

@zygoloid zygoloid added the changes requested Changes to the wording or approach have been requested and not yet applied. label Mar 12, 2020
@jensmaurer
Copy link
Member

jensmaurer commented Mar 12, 2020

While I very much appreciate a general cleanup in this area, I'm mildly favoring a core issue for this, or at least CWG review of the editorial change. @zygoloid , are you reasonably sure we're not destroying int (*p)() vs. int *p() with the reformulation? (The reformulation looks reasonable to me, but this is not the first time in history that CWG was bitten by this wording. Maybe that's an argument for refomulating.) Note that we've lived with the status quo since C++98, so I'm slightly uneasy about a last-minute fix for C++20.
Please don't read this as a veto, just as a "github diff format isn't really the right tool for this kind of change".

@sdkrystian
Copy link
Contributor Author

@zygoloid I applied the changes you suggested, but rather than referring to "the declared entity", I changed it to refer to the declarator-id itself.

@sdkrystian
Copy link
Contributor Author

@jensmaurer I walked through a few complex declarators manually following the new wording and it all checks out.

@jensmaurer jensmaurer removed the changes requested Changes to the wording or approach have been requested and not yet applied. label Oct 29, 2020
@tkoeppe
Copy link
Contributor

tkoeppe commented Dec 14, 2020

@sdkrystian: could you please rebase this (maybe after the mailing goes out), and let me know, and then I'll ask CWG to review this. The cleanup looks laudable, but I'd like some committee oversight on it.

@jensmaurer jensmaurer added the needs rebase The pull request needs a git rebase to resolve merge conflicts. label Mar 15, 2021
@sdkrystian
Copy link
Contributor Author

sdkrystian commented Nov 7, 2023

@jensmaurer @tkoeppe I apologize for going dark for the last few years... I will be going through my open PRs and addressing comments/rebasing over the coming weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs rebase The pull request needs a git rebase to resolve merge conflicts.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants