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] Improve clarity of presentation #4611

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

Conversation

zygoloid
Copy link
Member

[dcl.meaning.general] is hard to read currently, mostly due to a dense nesting of "if" / "otherwise" clauses where it's not always clear which wording is in the scope of which "if"s, and what each "otherwise" binds to. This PR attempts to clean this up a bit.

In passing, I also fixed an issue where we use the same name S for two different purposes in the same scope, and front-loaded the "declarator-id is normally not looked up" rule so that the special cases where lookup does happen are more obvious.

@opensdh Your review in particular would be appreciated.

of name matching more readable.

Avoid shadowing the name S with a different meaning in the same
paragraph by moving the block-scope extern handling to its own
paragraph.
looked up" wording earlier and explicitly call out the special cases.
are considered when identifying
any function template specialization being declared\iref{temp.deduct.decl}.
any function or variable template specialization
Copy link
Member Author

Choose a reason for hiding this comment

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

@opensdh Was the different treatment of function and variable template specializations intended?

Copy link
Contributor

Choose a reason for hiding this comment

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

It was (although that doesn't guarantee that it's good to do so!). The idea is that we do ordinary lookup for the name before the < (and for an explicit specialization/instantiation without an explicit template argument list, for consistency): if we find a variable template, it must be the unique lookup result, so there isn't any reason to disqualify that one result because of nominability. I think we did talk about this in the review, but I can't find the minutes for it.

If it declares a class member,
the terminal name of the \grammarterm{declarator-id} is not looked up;
otherwise, only those lookup results that are nominable in $S$
If such a \grammarterm{declarator} does not declare a class member,
Copy link
Member Author

Choose a reason for hiding this comment

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

@opensdh I tried to figure out why we're treating class members differently from non-class-members here and didn't succeed. Perhaps an example would help? I'm also not sure how we're supposed to handle an explicit specialization of a class member template without performing name lookup. Was the intent here instead that if the specialization or instantiation is for a non-template member of a class template specialization, no lookup is performed?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that you're right: we do have to do the lookup for the same reason that we have to do it when encountering template<> my_namespace::my_class< since it might continue int>::sub_template<int> { or just int> {. You're probably right about the intent too, but I'm less clear on that at the moment. (My plan is to, tomorrow, look at your wording here and see if I see any problems with it of a similar sort; if not, it stands to reason that it reflects the intent better.)

@opensdh
Copy link
Contributor

opensdh commented Jun 3, 2021

I will get to this, but I'm out for about a week starting now (and expect to be at least as busy with Real Work when I return as I am now).

Copy link
Contributor

@opensdh opensdh left a comment

Choose a reason for hiding this comment

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

This is a less drastic change than I expected before reading it carefully. The change about variable templates doesn't seem eminently editorial, but neither does it necessarily need more than a cursory CWG review.

the declaration shall correspond to a declaration
that inhabits the innermost block scope.
\end{itemize}

\pnum
Otherwise:
If the declaration is not a friend declaration:
Copy link
Contributor

Choose a reason for hiding this comment

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

As this is exhaustive together with the previous paragraph, I'd prefer to use one of our formulations that indicates that: perhaps

Otherwise, the declaration is not a friend declaration:

or

Otherwise (for a non-friend declaration):

Comment on lines 2536 to 2538
If the \grammarterm{declarator} declares
an explicit instantiation or a partial or explicit specialization,
the \grammarterm{declarator} does not bind a name.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is actually redundant: such declarations do not introduce names ([temp.explicit]/5, [temp.expl.spec]/4, and [temp.spec.partial.general]/7), so [basic.scope.scope]/2.5 ignores them already. This is relevant because it is an opportunity to merge into the next sentence (once we're sure exactly what we mean it to mean).

@tkoeppe
Copy link
Contributor

tkoeppe commented Jun 17, 2021

@opensdh, @zygoloid: (given there are still unresolved discussions:) if you can agree on a clear improvement, we can try to land this for the upcoming WD, but no rush.

@jensmaurer jensmaurer added the changes requested Changes to the wording or approach have been requested and not yet applied. label Oct 25, 2021
@jensmaurer
Copy link
Member

@zygoloid , looks like there are some changes still open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes requested Changes to the wording or approach have been requested and not yet applied. 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

5 participants