When I say "comment out", does it mean to uncomment something or comment it?
What is better, or more correctly used?
PS: I'm talking about source code.
When I say "comment out", does it mean to uncomment something or comment it?
What is better, or more correctly used?
PS: I'm talking about source code.
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.
"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.
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 removing a comment.
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
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.
//That is a function for calculating 2 intgers and display the result. - this is a comment
int add(int a, int b)
{
return a+b;
print(a+b);
}
Now, you think the "print(a+b)" is useless, you don't want it anymore, but you want to remain it at here in case whenever you want to reuse it. You don't have to delete this line, you can just comment out it like that,
int add(int a, int b)
{
return a+b;
//print(a+b);
}