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
Conversation
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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...?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 anArray
template might provide a common definition for, respectively, a dynamic linked list or a contiguous array of elements of an arbitrary type. TheArray
template might be [...]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zygoloid: Ping
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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 classList<T>
for each typeT
, describing a linked list of elements of typeT
. Similarly, a class templateArray
describing a contiguous, dynamic array might be defined as follows:
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
2204964
to
47275d2
Compare
I just changed "The prefix |
Replaces #1177.