Take the 2-minute tour ×
English Language & Usage Stack Exchange is a question and answer site for linguists, etymologists, and serious English language enthusiasts. It's 100% free, no registration required.

When I say "comment out", does it mean to uncomment something or comment it?
What is more better, or correctly, used?

PS: I'm talking about source code.

share|improve this question

5 Answers 5

up vote 32 down vote accepted

To comment out is to render a block of code inert by turning it into a comment.

In C# code for example, commenting out code is done by putting // at the start of a line, or surrounding the code with /* and */. Here the line inside the loop is commented out:

for (int i = 0: i < 10; i++) {
  //Console.WriteLine(i);
}

To uncomment something means to remove the characters that makes it a comment. The expression only makes sense if the comment contains something that would work as code, usually something that was commented out earlier. To uncomment a regular comment would just cause a syntax error.

share|improve this answer

"Comment out" means to use comment syntax to remove something from the parsed code. "Uncomment" is the reverse operation. They are both the correct expression for their respective referents.

share|improve this answer
    
so it means something like "Remove out this line by commenting it" ? –  genesis Jul 9 '11 at 11:53
2  
@Genesis: To clarify, as I understand it, to comment out means to leave the unwanted code unchanged, but insert before it (and after, for multi-line comments) the relevant character sequence that makes the compiler ignore that code when compiling. In C++ that's a double-slash before it on a single-line, or slash/asterisk before and asterisk/slash after where multiple lines are being commented out. –  FumbleFingers Jul 9 '11 at 12:37
2  
I don't understand what that means. Are you just saying that as an alternative to enclosing the entire unwanted section in "begin/end comment" delimiters, you can prefix each line with the sequence that means "the rest of this line is a comment". The important point is that the unwanted code itself remains unchanged - it's just that the compiler/interpreter is directed to ignore it. –  FumbleFingers Jul 9 '11 at 13:36
2  
I never mentioned "the line" anywhere when referring to what was to be commented out. I called it "the unwanted code", which could be anything from part of a line to a substantial section of code. –  FumbleFingers Jul 9 '11 at 14:10
1  
No worries. I think yours is the best answer anyway, but when OP paraphrased it back as "remove out this line" I thought he might not have understood the answer fully. So it seemed important to clarify that the actual text of the code being "commented out" remains unchanged - you just mark it so it's ignored. –  FumbleFingers Jul 10 '11 at 16:19

As reported by the NOAD, the meaning of comment out is "(computing) turn part of a program into a comment so that the computer ignores it when running the program."

You could try commenting out that line.

The definition provided by Dictionary.com is the following one:

To surround a section of code with comment delimiters or to prefix every line in the section with a comment marker. This prevents it from being compiled or interpreted.

The PC Magazine Enciclopedia defines comment out using the following words:

To disable lines of code in a program by surrounding them with comment-start and comment-stop characters.

Answers.com defines comment out as "(computer science) To render a statement in a computer program inactive by making it a comment."

Comment out doesn't mean to remove a comment, but to add a comment to ,e.g., a code line to avoid it gets compiled or interpreted.

share|improve this answer

The idea is "remove by commenting/turning into a comment". Note that "out" is used to mean remove in a number of phrasal verbs: "dig out", "force out", "smoke out" etc-- and indeed, on more or less the same analogy "wipe out".

As the opposite, you can "uncomment" a line/section, or you "comment it back in". The latter is slightly odd, because logically you are uncommenting so that the code to be put back in. But hey, language doesn't always use the same logic as mathematics.

share|improve this answer

For me when you comment it is to clarify something that will make it easier for the user to understand like in c++(although a simple example and should not be used like this):

int n = 0;
//add 4 to variable n and then output it
n += 4;
cout << n;

But shall someone say comment out I think of the coder commenting out a line or section of code to see what happens with program execution. Such as this:

First code:

int n = 0;
n += 4;
cout << n;

And then commenting out a line to see what will happen with the program:

int n = 0;
//n += 4;
cout << n;

The first code will output 4 but when I comment out the second line it will output 0 I simply use this so that I don't have to delete code and then rewrite it because twe

share|improve this answer

protected by tchrist Aug 13 at 14:36

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.