Content deleted Content added
Added knowledge Tags: Reverted Visual edit |
Velocifyer (talk | contribs) |
||
(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}}
{{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]],
=== 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
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
<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
|