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.class] Reorganize examples into separate paragraph #1180

Merged
merged 1 commit into from Dec 14, 2016

Conversation

tkoeppe
Copy link
Contributor

@tkoeppe tkoeppe commented Dec 7, 2016

Replaces #1177.

@Eelis
Copy link
Contributor

Eelis commented Dec 7, 2016

Nice! I was also going to submit a pull request similar to #1177 for the example spanning [class.access]#6-7, but maybe you want to reorganize that one as well?

The prefix
\tcode{template}
\tcode{<class}
\tcode{T>}
specifies that a template is being declared and that a
\grammarterm{type-name}
\tcode{T}
will be used in the declaration.
will be used in the definition.
Copy link
Member

Choose a reason for hiding this comment

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

This change seems unnecessary; a template parameter can be used in a non-defining declaration too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But the example doesn't do that. The example should help make things clear, not list unrelated, though un-wrong, statements. Should we maybe delete the sentence?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or we could say "in the declaration or definition".

Copy link
Contributor

Choose a reason for hiding this comment

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

All definitions are also declarations...?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@timsong-cpp: Yes, but not all declarations are definitions. To repeat, I think the example should be useful, otherwise we can just remove it. This change is an attempt to make the sentence relevant to the example and help the illustraion, rather than be a general statement that happens to be true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@timsong-cpp: Let me try again. I think that the value of an example lies in its power of illustration. That is, specification should be general, and illustration should be specific. You want to give the reader as much insight into the details as possible. For example, a declaration is valid C++, so you could also say, "The following code might appear in a C++ program." That would also be correct, but it would illustrate less. I'd like the explanation of example code to point out as specific a level of detail as is relevant to the subject it's an example of. Does that make sense?

Copy link
Contributor

@Eelis Eelis Dec 8, 2016

Choose a reason for hiding this comment

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

The "WILL" part seems dubious to me. I'd go for "MAY be used in the declaration", because the sentence does sound like a general-ish description of the meaning of the "template <class T>" prefix to me, even though it appears in an example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Eelis: How about "is", since the example is indeed using it?

Copy link
Contributor

Choose a reason for hiding this comment

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

It is indeed using it, but that fact is not specified by the prefix. The prefix merely specifies the possibility. So if the goal of the sentence is to describe the meaning of the prefix, that's what it ought to say. Just my interpretation :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Eelis: Yes, I agree. "May" sounds good.

@@ -1375,11 +1377,7 @@
\tcode{float},
and list of pointers to
\tcode{Shape}s.
Copy link
Member

Choose a reason for hiding this comment

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

This sentence seems strange; it appears to be suggesting that a List template might only work for some finite set of specified types. Maybe we could remove this (or rephrase it) rather than incorporating it into the somewhat-more-reasonable Array example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about:

A List template or an Array template might provide a common definition for, respectively, a dynamic linked list or a contiguous array of elements of an arbitrary type. The Array template might be [...]

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: Ping

Copy link
Member

Choose a reason for hiding this comment

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

I think it's lacking something -- I think we want to more explicitly say that a single List template can simultaneously provide definitions for lists of type T, for all possible types T.

Copy link
Contributor Author

@tkoeppe tkoeppe Dec 12, 2016

Choose a reason for hiding this comment

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

@zygoloid: How about:

A single class template List might provide an unbounded set of class definitions: one class List<T> for each type T, describing a linked list of elements of type T. Similarly, a class template Array describing a contiguous, dynamic array might be defined as follows:

Copy link
Member

Choose a reason for hiding this comment

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

Sure, let's go with that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, now it looks like this:

image

The prefix
\tcode{template}
\tcode{<class}
\tcode{T>}
specifies that a template is being declared and that a
\grammarterm{type-name}
\tcode{T}
will be used in the declaration.
may be used in the definition.
Copy link
Contributor

Choose a reason for hiding this comment

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

"specifies that a template is being declared and that a type-name T may be used in the definition" simply doesn't make much sense to me, sorry. Similar to the argument for "may" here, at this point in time we don't know if the prefix is being followed by a definition or a (non-defining) declaration yet, so I still think "declaration" makes more sense. But at least the two highlighted words should match.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, you're right, I'll back those changes out for now. It seems like the status quo is fine, and this isn't making it better.

@tkoeppe tkoeppe force-pushed the tempex branch 4 times, most recently from 2204964 to 47275d2 Compare December 14, 2016 23:26
@tkoeppe
Copy link
Contributor Author

tkoeppe commented Dec 14, 2016

image

@tkoeppe
Copy link
Contributor Author

tkoeppe commented Dec 14, 2016

I just changed "The prefix template <class T> to "The prefix template<class T>" for local consistency.

@zygoloid zygoloid merged commit 19a0c06 into cplusplus:master Dec 14, 2016
@tkoeppe tkoeppe deleted the tempex branch December 14, 2016 23:45
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