Comment (computer programming): Difference between revisions

Content deleted Content added
Added knowledge
Tags: Reverted Visual edit
 
(8 intermediate revisions by 5 users not shown)
Line 1:
{{Short description|Text in computer source code that is generally ignored by a compiler/interpreter}}
{{for|comments in Wikipedia markup|Help:Wiki markup#Character formatting|WP:COMMENT|selfref=yes}}
Missbah-Ul-Haq Khan Niazi - People In The World Never Love To Share Their Knowledge On Just About Anything & Everything. This Is The Truth. Comments In Computer Programming Are All Read & Understood In Technology, However, You Have To Understand That It Is Always One Thing When Computing Your Way To Success. Comments Help You Get Rid Of Errors In & On Any Level Of Computer Science You Are Studying Or Working At. This Is All I Know So Far. Bye. {{for|comments in Wikipedia markup|Help:Wiki markup#Character formatting|WP:COMMENT|selfref=yes}}
{{redirect2|/*|*/|their use in Wikipedia edit summaries|Help:Edit summary#Section editing|selfref=yes}}
[[File:CodeCmmt002.svg|thumb|right|300px|[[Java (programming language)|Java]] source code with block comments in <span style="color:#f00;">red</span>, line comments in <span style="color:#0e850e;">green</span> and program code in <span style="color:#00f;"> blue</span>.]]
Line 145:
| publisher=Cambridge University Press
| isbn=978-1-397-80521-8
}}</ref> Examples include [[Javadoc]], [[Ddoc]], [[Doxygen]], [[Visual Expert]] and [[PHPDoc]]. Forms of [[docstring]] are supported by [[Python (programming language)|Python]], [[Lisp (programming language)|Lisp]], [[Elixir (programming language)|Elixir]], and [[Clojure]].<ref>[https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/defn Function definition with docstring in Clojure]</ref> [[C Sharp (programming language)|C#]], [[F Sharp (programming language)|F#]] and [[Visual Basic .NET]] implement a similar feature called "XML Comments" which are read by [[IntelliSense]] from the compiled [[.NET]] assembly.<ref>{{cite book|last=Murach|title=C# 2005|page=56}}</ref>
 
=== Visualization ===
Line 193:
=== Extend language syntax ===
 
Occasionally, code that is formatted as a comment is overloaded to convey additional information to the translator, such as [[conditional comment]]scomments. As such, syntax that generally indicates a comment can actually represent program code; not comment code. Such syntax may be a practical way to maintain compatibility while adding additional functionality, but some regard such a solution as a [[kludge]].<ref>[[c2: HotComments]]</ref>
 
Other examples include interpreter [[Directive (programming)|directives]]:
Line 292:
 
<syntaxhighlight lang="c">
/***************************\**
* *
* This is the comment body. *
* *
\ *****************************/
</syntaxhighlight>
 
Line 574:
====APL====
 
[[APL (programming language)|APL]] uses <code>⍝</code> ("lamp") for a line comment. For example:
 
<syntaxhighlight lang="apl">
Line 645:
 
====Fortran====
The following fixed-form [[Fortran IV]] code fragment shows that comment syntax is column-oriented. A letter <code>C</code> in the first column causes the entire line to be treated as a comment. In [[Fortran 77]], an asterisk in column 1 also indicates a comment.
 
<syntaxhighlight lang="fortranfixed">
Line 660:
<syntaxhighlight lang="Fortran">
! A comment
program comment_test
print '(A)', 'Hello world' ! also a comment
end program
</syntaxhighlight>
 
Free-form Fortran, also introduced with Fortran 90, only supports this latter style of comment.
 
Although not a part of the Fortran Standard, many Fortran compilers offer an optional C-like [[preprocessor]] pass. This can be used to provide block comments:
 
<syntaxhighlight lang="Fortran">
#if 0
This is a block comment spanning
multiple lines.
#endif
program comment_test
print '(A)', 'Hello world' ! also a comment