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
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.
Looks fine (and is an improvement). It would be good if the line breaks wouldn't follow a troff tradition.
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.
I think we can clean this up quite a bit more. Suggestion follows.
source/declarations.tex
Outdated
\tcode{T} | ||
determines the type | ||
\tcode{T}. | ||
First, the type \tcode{T} is determined. |
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.
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: ...
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.
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
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}''. |
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.
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 toT
''.
(And so on for later subclauses.)
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.
@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?
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.
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)
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 |
@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. |
@jensmaurer I walked through a few complex declarators manually following the new wording and it all checks out. |
@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 @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. |
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 thatT
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 forT 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.