5

I'm the kind of person who is irked by poor spelling and grammar, so when I see a post with these sorts of errors I usually try to fix it. I recently stumbled upon a question with typos not only in the description of the problem, but in the comments in the code provided.

Obviously, changing code in any functional manner shouldn't be done except in specific circumstances, but what about changing comments to make them more legible?

I chose to leave them for now, (partially to make sure my edit got approved, so the other typos would be banished from the question), but I wanted to know if that was the right call.

4
  • 2
    There is a danger in editing code, including comments: You may accidentally obscure the problem. If you are just editing to satisfy an itch without adding real value to the question, my vote is that you leave it alone. Commented Jul 31, 2013 at 17:19
  • 3
    @GeorgeCummins Out of curiosity, how would fixing spelling/grammar in a comment obscure the problem?
    – StephenTG
    Commented Jul 31, 2013 at 17:25
  • See the top two answers here. Their conclusions: "unless it's just a case of highlighting code as code, so that it displays nicely, you shouldn't change the code." and "Improving the grammar and spelling of the actual question is one thing, but changing code is a minefield." Commented Jul 31, 2013 at 17:35
  • 2
    @George however I disagree that a comment embedded in code is strictly code. Since if you remove it entirely, the code will still work. I don't see any harm in fixing spelling and grammar there, as long as there aren't any potential issues like the one djechlin pointed out (e.g. you should test that the code still compiles and runs as intended, and if it doesn't, maybe that is better criteria for leaving it alone).
    – Aaron Bertrand Staff
    Commented Jul 31, 2013 at 17:41

2 Answers 2

8

The important thing is just to do it right. There is, after all, this behavior:

 // Will the next line be executed??/
 a++;

And if you remove the ?/ the behavior will, in fact, be changed.

A similar problem, that someone feels is the most stupid C bug ever:

else if (code == 200) {     // Downloading whole file
    /* Write new file (plus allow reading once we finish) */
    // FIXME Win32 native version fails here because Microsoft's version of tmpfile() creates the file in C:\
    g = fname ? fopen(fname, "w+") : tmpfile();
}

These are quite rare, but, even when editing comments in code, please be conscientious of things like this escaping issue.

3
  • Ah, that's definitely a good thing to be aware of. Here's a link to the post in question: stackoverflow.com/questions/17976681/…
    – StephenTG
    Commented Jul 31, 2013 at 17:40
  • Regarding the "most stupid C bug ever", why is there a line continuation character () for a single-line comment? Curious design. Commented Jul 31, 2013 at 17:45
  • @OldCheckmark the line continuation character is general it not just for single line comments. It is also processed before comments are removed from the document.
    – FDinoff
    Commented Jul 31, 2013 at 18:06
12

If you're fixing spelling and grammar in the rest of the post, I would fix these as well. Do as much as you can to make the post attractive and easy to read while editing.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .