Comment (computer programming): Difference between revisions

Content deleted Content added
Common attributes: Organize info better
Common attributes: add example
Line 48:
}}</ref> A '''line comment''' ends at the end of the text line. In modern languages, a line comment starts with a delimiter but some older languages designate a column at which subsequent text is considered comment.<ref name="javadude000" /> Many languages support both block and line comments {{endash}} using different delimiters for each. For example, [[C (programming language)|C]], [[C++]] and their many derivatives support block comments delimited by <code>/*</code> and <code>*/</code> and line comments delimited by <code>//</code>. Other languages support only one type of comment.<ref name="javadude000" />
 
Comments can also be classified as either prologue or inline based on their position and content relative to program code. A '''prologue comment''' is a comment (or group of related comments) located near the top of an associated programming topic, such as before a symbol declaration or at the top of a file,. is called aAn '''prologueinline comment'''. Ais a comment that is located on the same line as and to the right of program code isto calledwhich anis '''inline comment'''refers.<ref name="JBDixit000">{{cite book | last = Dixit | first = J.B. | title = Computer Fundamentals and Programming in C | publisher = Laxmi Publications | year = 2003 | isbn = 978-81-7008-882-0 }}</ref> Both prologue and inline comments can be represented as either line or block comments. For example:
 
<syntaxhighlight lang="c">
/*
* prologue block comment; if is about foo()
*/
bool foo() {
return true; /* inline line comment; if is about this return */
}
 
//
// prologue line comment; if is about bar()
//
bool bar() {
return false; // inline line comment; if is about this return
}
</syntaxhighlight>
 
==Examples of use==