[temp.variadic] Use consistent utterances associated with pack expansion
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 221
- Forks
- 813
- Avg merge
- 16h 4m
- Merged PRs (30d)
- 36
Description
[temp.variadic] p5 and [temp.variadic] p8 states
A pack expansion consists of a pattern and an ellipsis, the instantiation of which produces zero or more instantiations of the pattern in a list (described below).
The instantiation of a pack expansion considers items...
Such two rules explicitly state that productions are produced from the instantiation of a pack expansion. However, in [temp.variadic] p8.2, we use a different utterance. [temp.variadic] p8.2 says:
if the pack is a function parameter pack, the element is an id-expression designating the ith function parameter that resulted from instantiation of the function parameter pack declaration;
[dcl.fct] p25 explicit defines that
When it is part of a parameter-declaration-clause, the parameter-declaration declares a function parameter pack ([temp.variadic]).
A function parameter pack is a pack expansion ([temp.variadic]).
From the above, we can get the following conclusion that
- the particular parameter-declaration declares a function parameter pack
- a function parameter pack is a pack expansion
Hence, we shouldn't say the instantiation of the function parameter pack declaration(i.e., the parameter-declaration is not a pack expansion). We should consistently say
if the pack is a function parameter pack, the element is an id-expression designating the ith function parameter that resulted from instantiation of the function parameter pack
declaration;
https://github.com/cplusplus/draft/issues/5165 has a similar issue.
[temp.variadic] p5.1
Pack expansions can occur in the following contexts:
- In a function parameter pack ([dcl.fct]); the pattern is the parameter-declaration without the ellipsis.
This bullet is a bit different from other bullets after it. The other context all refers to the grammar component that contains the ellipsis. In the initial of p5, we have emphasized that a pack expansion consists of a pattern and an ellipsis. That is, the grammar component that contains the ellipsis conforms to the definition of a pack expansion. Not only from this point but also from [temp.param] p17, they all expose that the definition in [dcl.fct] p25 is contradictory.
From [temp.param] p17
If a template-parameter is a type-parameter with an ellipsis prior to its optional identifier or is a parameter-declaration that declares a pack ([dcl.fct]), then the template-parameter is a template parameter pack.
we can get a conclusion that
- if a template-parameter that is a parameter-declaration that declares a pack, then the template-parameter is a template parameter pack,
- since template-parameter is the parameter-declaration, the parameter-declaration is a template parameter pack.
Conversely, [dcl.fct] p25 says
Otherwise, the parameter-declaration is part of a template-parameter-list and declares a template parameter pack; see [temp.param].
This rule uses "declares" not "is". we may read the contradiction from such two formal rules. Moreover, [temp.variadic] p5.1 is uncoordinated. I think we may change [dcl.fct] p25
A declarator-id or abstract-declarator containing an ellipsis shall only be used in a parameter-declaration. When it is part of a parameter-declaration-clause, the parameter-declaration declares a function parameter pack ([temp.variadic]). Otherwise, the parameter-declaration is part of a template-parameter-list and declares a template parameter pack; see [temp.param]. Such parameter-declaration is a pack expansion ([temp.variadic]).
change [temp.param] p17 to
If a template-parameter is a type-parameter with an ellipsis prior to its optional identifier or is a parameter-declaration that declares a pack ([dcl.fct]), then the template-parameter
isdeclares a template parameter pack. A parameter-declaration declaring a template parameter pack whose type contains one or more unexpanded packs is a pack expansion. Similarly, a type-parameter, with a template-parameter-list containing one or more unexpanded packs, that declares a template parameter pack is a pack expansion. A type-parameter with a type-constraint that contains an unexpanded parameter pack is a pack expansion. A template-parameter that is a pack expansion shall not expand a template parameter pack declared in the same template-parameter-list.
change [temp.variadic] p5.1 and p5.3 to
Pack expansions can occur in the following contexts:
- In a parameter-declaration that declares a function parameter pack; the pattern is the parameter-declaration without the ellipsis.
- [...]
- In a template-parameter that is a pack expansion ([temp.param]):
- if the template-parameter is a parameter-declaration; the pattern is the parameter-declaration without the ellipsis;
- if the template-parameter is a type-parameter; the pattern is the corresponding type-parameter without the ellipsis.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing [temp.variadic] p5, p5.1, p5.3, and p8 with [dcl.fct] p25 and [temp.param] p17, including the related issue #5165. Determine whether the proposed terminology and pack-expansion rules are consistent across these clauses; done means an agreed wording change that resolves the identified contradictions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, tex
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100