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

OK, error, ambiguous consistency of comments in examples. #971

Closed
wants to merge 9 commits into from

Conversation

vgvassilev
Copy link

Current stats:

git grep '// OK,' | wc -l
      60
git grep '// OK:' | wc -l
     246
git grep '// error,' | wc -l
      22
git grep '// error:' | wc -l
     257
git grep '// Error' | wc -l
       7

This PR introduces:

  // OK, -> // OK:
  // Error -> // error
  // error[,] -> // error:
  // ambiguous[,] -> ambiguous:
  // error[:] ambiguous[,]-> error: ambiguous:

If you consider this as an improvement please merge.

Copy link
Member

@zygoloid zygoloid left a comment

Choose a reason for hiding this comment

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

I think this needs more of a case-by-case approach. A colon makes sense when the following wording is the reason why the line is OK or an error, but does not make sense when we're saying both that it's OK (say) and something else about it. I've marked up some individual cases that are better without this change.

@@ -840,15 +840,15 @@
class Y;
extern void b();
class A {
friend class X; // OK, but \tcode{X} is a local class, not \tcode{::X}
friend class X; // OK: but \tcode{X} is a local class, not \tcode{::X}
Copy link
Member

Choose a reason for hiding this comment

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

This one should stay as a comma

friend void b(); // OK
friend void c(); // error
};
X* px; // OK, but \tcode{::X} is found
Z* pz; // error, no \tcode{Z} is found
X* px; // OK: but \tcode{::X} is found
Copy link
Member

Choose a reason for hiding this comment

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

This one too.

@@ -945,7 +945,7 @@

typedef int I;
class D {
typedef I I; // error, even though no reordering involved
typedef I I; // error: even though no reordering involved
Copy link
Member

Choose a reason for hiding this comment

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

This one should stay as-is.

@@ -905,7 +905,7 @@
\begin{codeblock}
constexpr int f(bool b)
{ return b ? throw 0 : 0; } // OK
constexpr int f() { return f(true); } // ill-formed, no diagnostic required
constexpr int f() { return f(true); } // ill-formed: no diagnostic required
Copy link
Member

Choose a reason for hiding this comment

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

This one should stay as-is, and likewise for other "ill-formed, no diagnostic required" cases.

@@ -1683,8 +1683,8 @@
body.
\begin{example}
\begin{codeblock}
auto f() { } // OK, return type is \tcode{void}
auto* g() { } // error, cannot deduce \tcode{auto*} from \tcode{void()}
auto f() { } // OK: return type is \tcode{void}
Copy link
Member

Choose a reason for hiding this comment

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

This one should stay as a comma. (We're not saying it's OK because the return type is void, we're saying both (a) it's OK, and (b) the return type is void.)

@@ -620,7 +620,7 @@
or allow it to be changed through a cv-unqualified pointer later, for example:

\begin{codeblock}
*ppc = &ci; // OK, but would make \tcode{p} point to \tcode{ci} ...
*ppc = &ci; // OK: but would make \tcode{p} point to \tcode{ci} ...
Copy link
Member

Choose a reason for hiding this comment

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

This one should stay as a comma.

@@ -2271,7 +2271,7 @@

\begin{codeblock}
struct onlydouble {
onlydouble() = delete; // OK, but redundant
onlydouble() = delete; // OK: but redundant
Copy link
Member

Choose a reason for hiding this comment

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

This one should be left alone.

@@ -2706,7 +2706,7 @@
\begin{codeblock}
int f(bool b) {
unsigned char c;
unsigned char d = c; // OK, \tcode{d} has an indeterminate value
unsigned char d = c; // OK: \tcode{d} has an indeterminate value
Copy link
Member

Choose a reason for hiding this comment

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

This one should probably be left alone, since it's really saying "OK, but d has an indeterminate value"

@vgvassilev
Copy link
Author

That makes sense to me. Is the list of comments what should be reverted exhaustive?

@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 13, 2016

Here's some tangential guidance: We all agreed that error: is the right way to state errors, because the cause of the error is something objective. If you like, you could factor out a change that only makes the error comments consistent.

By contrast, "OK" doesn't generally have a natural explanation other than "it's OK because it follows the rules of the standard". Any additional explanation that you choose to call out is subjective. So we're actually fine with `OK, ..." in general, but we can discuss individual change suggestions. But expect that part of the change to take more work.

@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 17, 2016

@vgvassilev: ping - this PR needs rebasing.

@vgvassilev
Copy link
Author

Rebased, addressing @zygoloid's comments.

@vgvassilev
Copy link
Author

@tkoeppe thanks for the comments. Who is "we"? I am happy to remove the OK part of the PR if requested. I feel some of these substitutions are valid.

@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 26, 2016

@vgvassilev: Please rebase and rescan the draft for new occurrences of the style you're changing.

Dawn Perchik and others added 9 commits November 28, 2016 13:51
@vgvassilev
Copy link
Author

@tkoeppe Done. It seems somebody did push -f and rewrote the history of the master, sigh...

There are a few occurrences of ill-formed; which I want to change to ill-formed: however I don't feel I should be piling more things on this PR.

@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 28, 2016

@vgvassilev: I'm sorry. We do that extremely rarely, and never after more than five or so minutes after a push. Very sorry if you got caught in a force-push.

@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 30, 2016

@zygoloid: I think you liked this PR in general. Could you review the updated situation?

base();
};
struct derived : base {};

derived d1{}; // Error. The code was well-formed before.
derived d1{}; // error: the code was well-formed before.
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 looks wrong.

Copy link
Member

Choose a reason for hiding this comment

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

Specifically, it's not an error because it was OK before. After the change the comment makes no sense. The comment is saying "This is an error but it was OK before" and the current text says that much better.

@jwakely
Copy link
Member

jwakely commented Nov 30, 2016

I don't think any of the s/OK,/OK:/ changes are improvements. Most of the capitalization changes and removing trailing whitespace changes are fine. The s/error,/error:/ changes are generally OK in isolation, but when they occur in a group that contains both "error," and "OK," changing only the errors to use colons looks visually inconsistent (as stated above, the "OK" ones usually shouldn't have colons).

Overall, I think this is an attempt to impose an unnecessarily rigid rule on free-text comments, which don't need to be globally consistent to some fixed rule. Local consistency and clarity of meaning is probably more important. As the current patch actually changes meaning in some cases and decreases legibility in other cases, I think it would make the standard worse, not better.

Individual pieces of this change would be fine where they improve clarity, but I don't like trying to address every instance at once just in the name of consistency.

@jwakely jwakely closed this Nov 30, 2016
@jensmaurer
Copy link
Member

See #5080 for further cleanup for "OK"

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

5 participants