cplusplus / draft

C++ standards drafts
http://www.open-std.org/jtc1/sc22/wg21/
5.61k stars 739 forks source link

[basic.pre] unintended re-definition of `declaration` #6753

Open h0nzZik opened 6 months ago

h0nzZik commented 6 months ago

It seems to me that 6.1.5 is formulated in a way that suggest that the sentence is actually a definition of declaration - and it is not:

Every name is introduced by a declaration, which is a [...]

According my interpretation of this Grammarly blog post, the ", which is a [...]" part is a nonrestrictive clause. That means that the sentence should make sense even without it, and the clause should only add some additional information. So the sentence is equivalent to saying

Every name is introduced by a declaration. By the way, a declaration is a [...]

But then (1) we would have two definitions of what a declaration is, and (2) we would not restrict which kinds of declarations can introduce names. This would be in contrast with what I am guessing is the intended meaning of the sentence - that is, to define the "can-introduce-a-name" property of declaration. In my opinion, the sentence should go like this:

Every name is introduced by a declaration that is a [...]

(that is, we should use a restrictive clause).

Disclaimer: I am not a native English speaker.

frederick-vs-ja commented 6 months ago

I think the italic style is making the paragraph a complete definition. IMO the Standardese is somehow different from the plain English.

h0nzZik commented 6 months ago

Ok, so whenever after 6.1.5 I see "declaration", it refers to this list in 6.1.5, and when I see "declaration", it refers to the grammar element? Usually grammar elements ("syntactic objects") are distinguished from other terms ("semantics objects") in that they use dashes/hyphens if they consist of multiple words, while the other terms use spaces - but "declaration" is only one word, so that is confusing.

Also, the following suggests that there is a term "declaration of E" (for an entity E), but such a term is not defined anywhere.

An entity E is denoted by the name (if any) that is introduced by a declaration of E or [...]

The same sentence suggests ("the name (if any)") that a "declaration of E" has associated an optional name. But the, 6.6.2 says

A declaration may (re)introduce one or more names and/or entities into a translation unit.

Which could be interpreted in two ways: either there are two terms, a "declaration" and a "declaration of E", and that would be ok. Or there is only one term, and then two cited sentences together imply that a declaration introduces exactly one name, in a weird way.