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

[temp.spec] Make "specialization" a proper definition & adjust definition. #3248

Merged
merged 6 commits into from Jan 14, 2020

Conversation

sdkrystian
Copy link
Contributor

Specialization is the second most common term that is defined and used in [temp]. The definition in [temp.spec] p4 should be italicized to make it a proper definition. Also, the phrase " function, or class member that is [...] explicitly specialized" is incorrect: templates are explicitly specialized, not classes, functions etc (in some cases non-templates too, but rarely).

Additionally, a specialization of a alias template (such as the use here: http://eel.is/c++draft/temp.alias#2) is meaningless for non-class types. Consider the following:

template<typename T>
using A = int;

A specialization is a class, function, variable, or class member. The type denoted (if you could even say that, since its replaced) by the simple-template-id A<void> is none of these.

@W-E-Brown
Copy link
Contributor

  1. I agree that we should consider italicizing "specialization" in this sentence.

  2. I doubt we need the 2 consecutive prepositions "for by" -- how about "via" instead?

  3. Most importantly, do we really consider "int" to be a specialization of "template using A = int;"? Yes, we obtain a type when an alias template is instantiated, but is that type in any sense a specialization? Alias templates seem rather unlike function, class, and variable templates in this regard.

@sdkrystian
Copy link
Contributor Author

Yeah, I had trouble thinking of a way to describe aliases, since instantiation produces no entity, rather, replacement occurs. Another option would be to stomp out all references to "alias specializations", and replace them with something to the effect of "template-id where the template-name denotes an alias template", or something similar.

source/templates.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.

It feels the \defn is editorial, but the rest is probably not. Please limit this pull request accordingly.

@jensmaurer jensmaurer added the changes requested Changes to the wording or approach have been requested and not yet applied. label Sep 26, 2019
@jensmaurer
Copy link
Member

The Travis CI check failed. Maybe there's a space at the end of a line or so. Please fix that.

instantiated or explicitly specialized\iref{temp.expl.spec}.
A \defn{specialization} is a class, variable, function, or class member that is either
instantiated\iref{temp.inst} from a template or produced by an
explicit specialization\iref{temp.expl.spec} of a template.
Copy link
Member

Choose a reason for hiding this comment

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

I am having second thoughts about "produced by ...". In fact, an explicit specialization is a class etc. right there; it doesn't obviously "produce" one. (Oh, and "produce" sounds awkward anyway.)
maybe "... or an explicit specialization of a template."
@zygoloid ?

Copy link
Member

Choose a reason for hiding this comment

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

Looks to me now.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, are the "from a template" additions correct? For cases like:

template<typename T> struct X {
  void f() {}
};

... is X<int>::f() instantiated from a template, or from a member of a template?

Copy link
Member

@zygoloid zygoloid Nov 26, 2019

Choose a reason for hiding this comment

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

Also, "is either instantiated from a template or an explicit specialization of a template" is missing a verb. Or what an explicit specialization? (If this is "or is an explicit specialization", what does that mean for members of templates:

template<typename T> struct Y {
  struct Z {};
};
template<> struct Y<int>::Z {};
template<> struct Y<float> { struct Z {}; };

... which of Y<int>::Z and Y<float>::Z are specializations? Do we really mean that the former is a specialization and the latter is not?)

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 I think both of these could be addressed by saying:

A specialization is a class, variable, function, or class member that is either instantiated from a template, or a member thereof, or is an explicit specialization of a template, or member thereof.

This seems a little clunky though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct, but the variable itself is not

Copy link
Member

Choose a reason for hiding this comment

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

Well, it was certainly intended that variable templates are also templated entities. Maybe we should simply say that a variable is an entity, then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A variable template is a template though, so it is a templates entity anyways.

Copy link
Member

Choose a reason for hiding this comment

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

So, we're good with "templated entity", and all we need is an updated pull request.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@jensmaurer jensmaurer removed the changes requested Changes to the wording or approach have been requested and not yet applied. label Nov 19, 2019
@zygoloid zygoloid merged commit 32f346c into cplusplus:master Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants