Comment out
From Wikipedia, the free encyclopedia
In computing the term commenting out refers to the practice of converting some source code within a file, or the contents of a software configuration file, as comments (often block comments) to a form that has no effect on the execution of a program.
In some cases the code is commented out by using a language construct that ensures it is never executed. For instance, a conditional statement that is always false or through the use of a preprocessor.
This is may be done when the code is redundant or obsolete, but is being left in the source to make the intent of the active code clearer, or when a piece of code is faulty and a temporary bypass is needed in order to debug another part of the code.
[edit] Problems with usage
Commenting out can be onerous in languages that do not have block comments, and has its own hazards in certain languages that do have block comments. For example, in C, the comment delimiters may not be nested, so /*/*Foo*/*/
is the comment /*Foo
, followed by the literal code characters */
, which can lead to bugs when a section of code containing block comments is commented out. In C, a conditional preprocessor directive should generally be used instead. Some languages, like Haskell, avoid this by allowing the nesting of block comments, so the example above (translated into Haskell) read {-{-Foo-}-}
and is actually the comment {-Foo-}
and no characters of code.
[edit] External link
This article is based in part on the Jargon File, which is in the public domain.