Comments: Difference between revisions
Added Deluge. |
|||
(409 intermediate revisions by more than 100 users not shown) | |||
Line 1: | Line 1: | ||
{{task|Basic language learning}} |
{{task|Basic language learning}} |
||
[[Category:Initialization]] |
|||
Demonstrate all ways to include text in a language source file which is completely ignored by the compiler or interpreter. |
|||
;Task: |
|||
Show all ways to include text in a language source file |
|||
that's completely ignored by the compiler or interpreter. |
|||
;Related tasks: |
|||
* [[Documentation]] |
|||
* [[Here_document]] |
|||
;See also: |
|||
* [https://en.wikipedia.org/wiki/Comment_(computer_programming) Wikipedia] |
|||
* [http://xkcd.com/156 xkcd] (Humor: hand gesture denoting <code>//</code> for "commenting out" people.) |
|||
<br><br> |
|||
=={{header|11l}}== |
|||
<pre>// Single line comment |
|||
\\ Also single line comment (continuation of the comment in previous line) |
|||
\[ This is |
|||
a multi line |
|||
comment ] |
|||
\{ And |
|||
this } |
|||
\( And |
|||
this ) |
|||
\‘ And |
|||
this ’</pre> |
|||
=={{header|360 Assembly}}== |
|||
<syntaxhighlight lang="360 assembly"> |
|||
* An asterisk in column one denotes a comment line |
|||
* Comments may also follow any syntactically complete instruction: |
|||
LA 1,0 Comment |
|||
NOP Comment (after a NOP instruction) |
|||
* Comments after instructions with omitted operands require a comma "," |
|||
END , Comment (without comma, "Comment" assumed an operand of "END") |
|||
</syntaxhighlight> |
|||
=={{header|4D}}== |
=={{header|4D}}== |
||
< |
<syntaxhighlight lang="4d">`Comments in 4th Dimension begin with the accent character and extend to the end of the line (until 4D version 2004). |
||
// This is a comment starting from 4D v11 and newer. Accent character is replaced by //</syntaxhighlight> |
|||
=={{header|4ME}}== |
|||
P:This is a comment |
|||
out{hi!} This i also a comment |
|||
# This is a Python-Like comment |
|||
E: |
|||
Anything after the "E:" command wont be executed |
|||
=={{header|6502 Assembly}}== |
=={{header|6502 Assembly}}== |
||
Note: syntax depends on the assembler software but use of a semicolon is fairly standard |
Note: syntax depends on the assembler software but use of a semicolon is fairly standard |
||
< |
<syntaxhighlight lang="6502 assembly"> nop ; comments begin with a semicolon</syntaxhighlight> |
||
=={{header|68000 Assembly}}== |
|||
Note: syntax depends on the assembler software but use of a semicolon is fairly standard |
|||
EASy68k uses * as the comment character. VASM uses a semicolon ; |
|||
<syntaxhighlight lang="68000devpac"> MOVEM.L D0-D7/A0-A6,-(SP) ;push all registers onto the stack</syntaxhighlight> |
|||
=={{header|8086 Assembly}}== |
=={{header|8086 Assembly}}== |
||
Note: syntax depends on the assembler software but use of a semicolon is fairly standard |
Note: syntax depends on the assembler software but use of a semicolon is fairly standard |
||
<lang |
<syntaxhighlight lang="asm"> MOV AX, 4C00h ; go back to DOS |
||
INT 21h ; BIOS interrupt 21 base 16</ |
INT 21h ; BIOS interrupt 21 base 16</syntaxhighlight> |
||
=={{header|AArch64 Assembly}}== |
|||
{{works with|as|Raspberry Pi 3B version Buster 64 bits}} |
|||
<syntaxhighlight lang="aarch64 assembly"> |
|||
/* ARM assembly AARCH64 Raspberry PI 3B */ |
|||
/* comments multi lines |
|||
end comments |
|||
*/ |
|||
// comment end of ligne |
|||
</syntaxhighlight> |
|||
=={{header|ACL2}}== |
|||
Just like Common Lisp: |
|||
<syntaxhighlight lang="lisp">; Single line comment |
|||
#| Multi-line |
|||
comment |#</syntaxhighlight> |
|||
=={{header|Action!}}== |
|||
Action! supports only single line comments which begin with semicolon. |
|||
<syntaxhighlight lang="action!">;This is a comment |
|||
PROC Main() ;This is a comment as well |
|||
RETURN</syntaxhighlight> |
|||
{{out}} |
|||
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Comments.png Screenshot from Atari 8-bit computer] |
|||
=={{header|ActionScript}}== |
=={{header|ActionScript}}== |
||
Line 18: | Line 99: | ||
=={{header|Ada}}== |
=={{header|Ada}}== |
||
< |
<syntaxhighlight lang="ada">-- All Ada comments begin with "--" and extend to the end of the line</syntaxhighlight> |
||
=={{header|Agena}}== |
|||
Agena has single line comments and two styles of multi-line comments. |
|||
<syntaxhighlight lang="agena"># single line comment |
|||
#/ multi-line comment |
|||
- ends with the "/ followed by #" terminator on the next line |
|||
/# |
|||
/* multi-line comment - C-style |
|||
- ends with the "* followed by /" terminator on the next line |
|||
*/</syntaxhighlight> |
|||
=={{header|ALGOL 60}}== |
|||
A comment in ALGOL 60 takes the place of a single instruction. |
|||
<syntaxhighlight lang="algol_60"> |
|||
'COMMENT' this is a first comment; |
|||
'COMMENT' |
|||
****** this is a second comment ****** |
|||
; |
|||
</syntaxhighlight> |
|||
=={{header|ALGOL 68}}== |
=={{header|ALGOL 68}}== |
||
Line 56: | Line 158: | ||
===With Extensions=== |
===With Extensions=== |
||
£ This is a hash/pound comment for a UK keyboard £ |
£ This is a hash/pound comment for a UK keyboard £ |
||
=={{header|ALGOL-M}}== |
|||
<syntaxhighlight lang="ALGOL"> |
|||
begin |
|||
comment - This form is borrowed from ALGOL 60; |
|||
% And this is borrowed from ALGOL W % |
|||
% ALGOL-M will not compile an "empty" program, so we have % |
|||
% to include at least one code-generating statement! % |
|||
write("This is only an exercise"); |
|||
end |
|||
</syntaxhighlight> |
|||
=={{header|ALGOL W}}== |
|||
Comments in Algol W can appear anywhere whitespace is allowed. A comment starts with the reserved word 'comment' and ends with the next semi-colon. Alternatively a comment can start with a percent sign and end with the next percent sign or semi-colon. |
|||
A single word in the form of an identifier following the reserved word 'end' is also a comment. |
|||
<syntaxhighlight lang="algolw">begin |
|||
comment a comment; |
|||
% another comment |
|||
; |
|||
% and |
|||
another |
|||
% |
|||
end this_word_is_also_a_comment.</syntaxhighlight> |
|||
=={{header|AmigaE}}== |
=={{header|AmigaE}}== |
||
< |
<syntaxhighlight lang="amigae">/* multiline comment |
||
are like C ... */ |
are like C ... */ |
||
-> this is a end of line comment</ |
-> this is a end of line comment</syntaxhighlight> |
||
=={{header|AngelScript}}== |
|||
<syntaxhighlight lang="angelscript">// This is a comment</syntaxhighlight> |
|||
=={{header|AntLang}}== |
|||
<syntaxhighlight lang="antlang">2 + 2 /This is a comment</syntaxhighlight> |
|||
=={{header|Apex}}== |
|||
<syntaxhighlight lang="apex"> |
|||
System.debug ('I will execute'); // This comment is ignored. |
|||
/* |
|||
I am a large comment, completely ignored as well. |
|||
*/ |
|||
</syntaxhighlight> |
|||
=={{header|APL}}== |
|||
<syntaxhighlight lang="apl">⍝ This is a comment</syntaxhighlight> |
|||
=={{header|AppleScript}}== |
|||
<syntaxhighlight lang="applescript"> |
|||
--This is a single line comment |
|||
display dialog "ok" --it can go at the end of a line |
|||
# Hash style comments are also supported |
|||
(* This is a multi |
|||
line comment*) |
|||
(* This is a comment. --comments can be nested |
|||
(* Nested block comment *) |
|||
*) |
|||
</syntaxhighlight> |
|||
{{works with|AppleScript|2.0}} |
|||
<syntaxhighlight lang="applescript">display dialog "ok" #Starting in version 2.0, end-line comments can begin with a hash</syntaxhighlight> |
|||
=={{header|Arendelle}}== |
|||
Arendelle uses C style comments |
|||
=={{header|ARM Assembly}}== |
|||
{{works with|as|Raspberry Pi}} |
|||
<syntaxhighlight lang="arm assembly"> |
|||
/* ARM assembly Raspberry PI comment one line */ |
|||
/* comment line 1 |
|||
comment line 2 |
|||
*/ |
|||
mov r0,#0 @ this comment on end of line |
|||
mov r1,#0 // authorized comment |
|||
</syntaxhighlight> |
|||
=={{header|Arturo}}== |
|||
<syntaxhighlight lang="rebol">; This is a simple single-line comment |
|||
a: 10 ; another single-line comment |
|||
; Now, this is a |
|||
; multi-line comment</syntaxhighlight> |
|||
=={{header|Asymptote}}== |
|||
<syntaxhighlight lang="asymptote">// double slash to newline</syntaxhighlight> |
|||
See [http://asymptote.sourceforge.net/doc/Programming.html programming introduction in the Asymptote manual]. |
|||
When reading data files a comment character in them can be specified as <code>comment="#"</code> etc. See [http://asymptote.sourceforge.net/doc/Files.html Files in the Asymptote manual]. |
|||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |
||
<syntaxhighlight lang="autohotkey">Msgbox, comments demo ; end of line comment |
|||
<lang AutoHotkey>Msgbox, comments demo ; end of line comment |
|||
/* |
/* |
||
multiline comment1 |
multiline comment1 |
||
multiline comment2 |
multiline comment2 |
||
*/</ |
*/</syntaxhighlight> |
||
For multi |
For multi-line comments, the '''/*''' and '''*/''' '''must''' be on their own separate lines. Nothing else can be on the same line. |
||
=={{header|AutoIt}}== |
=={{header|AutoIt}}== |
||
<syntaxhighlight lang="autoit"> |
|||
<lang AutoIt> |
|||
#cs |
#cs |
||
Everything between the cs and and the ce is commented. |
Everything between the cs and and the ce is commented. |
||
Line 80: | Line 280: | ||
#ce |
#ce |
||
;individual lines after a semicolon are commented. |
;individual lines after a semicolon are commented. |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|AWK}}== |
=={{header|AWK}}== |
||
Line 86: | Line 286: | ||
The ''hash'' symbol # start a comment; it ends at the end of line. |
The ''hash'' symbol # start a comment; it ends at the end of line. |
||
< |
<syntaxhighlight lang="awk">BEGIN { # this code does something |
||
# do something |
# do something |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Axe}}== |
|||
<syntaxhighlight lang="axe">.This is a single-line comment</syntaxhighlight> |
|||
<syntaxhighlight lang="axe">... |
|||
This is a multi-line comment |
|||
...</syntaxhighlight> |
|||
<syntaxhighlight lang="axe">...If 0 |
|||
This is a comment only if the condition evaluates to zero |
|||
...</syntaxhighlight> |
|||
<syntaxhighlight lang="axe">...!If 1 |
|||
This is a comment only if the condition evaluates to nonzero |
|||
...</syntaxhighlight> |
|||
<syntaxhighlight lang="axe">...Else |
|||
This is a comment only if the previous conditional comment was executed (and vice versa) |
|||
...</syntaxhighlight> |
|||
=={{header|Babel}}== |
|||
<syntaxhighlight lang="babel"> |
|||
-- This is a line-comment |
|||
# |
|||
This is a block-comment |
|||
It goes until de-dent |
|||
dedent: 0x42 -- The comment block above is now closed |
|||
</syntaxhighlight> |
|||
=={{header|BASIC}}== |
=={{header|BASIC}}== |
||
Line 97: | Line 328: | ||
{{works with|Applesoft BASIC}} |
{{works with|Applesoft BASIC}} |
||
{{works with|Commodore BASIC}} |
|||
{{works with|GW-BASIC}} |
{{works with|GW-BASIC}} |
||
{{works with|ZX Spectrum Basic}} |
{{works with|ZX Spectrum Basic}} |
||
{{works with|uBasic/4tH}} |
|||
The only truly standard method of marking a comment in BASIC is using the <code>REM</code> keyword. This dates back to (at least) the late 1970's, and ''should'' work with most BASICs available today: |
The only truly standard method of marking a comment in BASIC is using the <code>REM</code> keyword. This dates back to (at least) the late 1970's, and ''should'' work with most BASICs available today: |
||
<syntaxhighlight lang="gwbasic">100 REM Standard BASIC comments begin with "REM" (remark) and extend to the end of the line |
|||
110 PRINT "this is code": REM comment after statement</syntaxhighlight> |
|||
{{works with|Applesoft BASIC}} |
|||
This may not be well known, but you may include text after the line number of GOTO and GOSUB statements. This is kind of a comment in absence of labels. |
|||
100 GOTO 200HERE |
|||
110 GOSUB 300THERE |
|||
120 GOTO 400THEOTHERPLACE |
|||
130 GOTO 500MOM AND POP |
|||
Spaces are removed from non-keyword text. BASIC keywords can be used. |
|||
List outputs spaces around keywords. |
|||
{{works with|QBasic|1.1}} |
|||
{{works with|QuickBASIC|4.5}} |
{{works with|QuickBASIC|4.5}} |
||
{{works with|uBasic/4tH}} |
|||
Most BASICs also support alternate comment characters, commonly an apostrophe (single quote): |
|||
Most BASICs also support alternate comment characters, |
|||
commonly an apostrophe (single quote): |
|||
<syntaxhighlight lang="qbasic"> 'this is a comment |
|||
PRINT "this is code" 'comment after statement |
PRINT "this is code" 'comment after statement</syntaxhighlight> |
||
{{works with|DarkBASIC}} |
{{works with|DarkBASIC}} |
||
Line 120: | Line 367: | ||
In addition to single-line comments, a few BASICs support block comments. FreeBASIC was influenced by [[Comments#C|the C family's]] block comment characters: |
In addition to single-line comments, a few BASICs support block comments. FreeBASIC was influenced by [[Comments#C|the C family's]] block comment characters: |
||
<!-- This is currently without syntax highlighting because whoever wrote freebasic.php for GeSHi didn't add the multi-line comments. --> |
|||
/' This is a multi line comment. |
/' This is a multi line comment. |
||
Requires FreeBASIC 0.16 or later. |
Requires FreeBASIC 0.16 or later. |
||
Line 125: | Line 373: | ||
DIM a AS /' Comment in the middle of statement '/ Integer |
DIM a AS /' Comment in the middle of statement '/ Integer |
||
==={{header|Applesoft BASIC}}=== |
|||
Comment by making a REMark using the REM keyword |
|||
<syntaxhighlight lang="qbasic">REM COMMENT AFTER THE REM KEYWORD</syntaxhighlight> |
|||
When LISTing the program a space is added after the REM keyword |
|||
<syntaxhighlight lang="qbasic">0 REMLEAVE THE SPACE OUT AFTER THE REM WHEN TYPING OR PASTING</syntaxhighlight> |
|||
The remark extends until the end of the line. Only the first THIS IS CODE is printed. |
|||
<syntaxhighlight lang="qbasic">10 PRINT "THIS IS CODE" : REM : PRINT "THIS IS CODE"</syntaxhighlight> |
|||
A comment can come after a GOSUB and when the subroutine returns it continues running the statements after the GOSUB comment. |
|||
<syntaxhighlight lang="qbasic">20 GOSUB 110COMMENT: PRINT "THIS IS CODE"</syntaxhighlight> |
|||
Anything after a GOTO or RETURN statement is ignored. |
|||
<syntaxhighlight lang="qbasic">30 GOTO 40"COMMENT: THIS IS A COMMENT</syntaxhighlight> |
|||
There are other ways to add spacing and comments to code. |
|||
<syntaxhighlight lang="qbasic">:::::::::::::::::::::::::::::::::::::: |
|||
40 REM |
|||
50 : |
|||
60 REM<ctrl>+J |
|||
70 FOR I = 1 to 10 |
|||
80 ::::PRINT I;MID$("THIS IS A COMMENT",1,0) |
|||
90 NEXT</syntaxhighlight> |
|||
Typing CONTinue after the program ENDs will result in a ?SYNTAX ERROR. |
|||
<syntaxhighlight lang="qbasic">100 END : THISISACOMMENT</syntaxhighlight> |
|||
Use the quotation symbol " before the comment so that spaces are included and keywords are ignored. |
|||
<syntaxhighlight lang="qbasic">110 RETURN : "COMMENT FOR AND AT THE END</syntaxhighlight> |
|||
==={{header|BaCon}}=== |
|||
BaCon accepts '''REM''' (or single quote apostrophe) for line comments. |
|||
C-style block comments can be used with <nowiki>/* and */</nowiki> pairs; these comment blocks may cross line boundaries. |
|||
Inside ''USEC'' sections, all comment styles accepted by the configured C compiler will also be ignored. |
|||
==={{header|BASIC256}}=== |
|||
<syntaxhighlight lang="basic256">rem this is a comment |
|||
# and this is too |
|||
print "this is code" #comment after statement</syntaxhighlight> |
|||
==={{header|Chipmunk Basic}}=== |
|||
{{works with|Chipmunk Basic|3.6.4}} |
|||
<syntaxhighlight lang="qbasic">10 rem this is a comment |
|||
20 ' and this is too |
|||
30 print "this is code" : 'comment after statement |
|||
40 print "and more code" : rem comment after statement</syntaxhighlight> |
|||
==={{header|IS-BASIC}}=== |
|||
<syntaxhighlight lang="is-basic">100 REM Standard BASIC comments begin with "REM" (remark) and extend to the end of the line |
|||
110 PRINT "this is code" ! comment after statement</syntaxhighlight> |
|||
==={{header|Minimal BASIC}}=== |
|||
<syntaxhighlight lang="qbasic">10 REM STANDARD BASIC COMMENTS BEGIN WITH "REM" AND EXTEND TO THE END OF LINE |
|||
20 END</syntaxhighlight> |
|||
==={{header|MSX Basic}}=== |
|||
<syntaxhighlight lang="qbasic">10 rem this is a comment |
|||
20 ' and this is too |
|||
30 print "this is code" : '[:] it's optional |
|||
40 print "and more code" : rem comment after statement</syntaxhighlight> |
|||
==={{header|Quite BASIC}}=== |
|||
<syntaxhighlight lang="qbasic">10 rem this is a comment |
|||
20 print "this is code" : rem comment after statement</syntaxhighlight> |
|||
==={{header|True BASIC}}=== |
|||
<syntaxhighlight lang="qbasic">!this is a comment |
|||
PRINT "this is code" !comment after statement</syntaxhighlight> |
|||
==={{header|XBasic}}=== |
|||
{{works with|Windows XBasic}} |
|||
{{works with|Linux XBasic}} |
|||
<syntaxhighlight lang="qbasic">PROGRAM "Comments" |
|||
VERSION "0.0000" |
|||
DECLARE FUNCTION Entry () |
|||
FUNCTION Entry () |
|||
'this is a comment |
|||
PRINT "this is code" 'comment after statement |
|||
END FUNCTION |
|||
END PROGRAM</syntaxhighlight> |
|||
==={{header|Yabasic}}=== |
|||
<syntaxhighlight lang="yabasic">rem Hey, this is a comment |
|||
# the hash-sign too (at beginning of line) |
|||
// even the double slash |
|||
' and the single quote (at beginning of line) |
|||
print "Not a comment" # This is an error !! |
|||
print "Not a comment":// But this is again a valid comment |
|||
print "Not a comment" // even this. |
|||
print "Not a comment" rem and this !</syntaxhighlight> |
|||
=={{header|Batch File}}== |
=={{header|Batch File}}== |
||
<lang |
<syntaxhighlight lang="dos">rem Single-line comment.</syntaxhighlight> |
||
There is another ( |
There is another (undocumented) option, using a double-colon <code>::</code>. However, this has issues with some syntactic constructs and therefore may raise syntax errors. |
||
< |
<syntaxhighlight lang="dos">:: Another option, though undocumented and known |
||
:: to fail in some cases. Best avoided.</ |
:: to fail in some cases. Best avoided.</syntaxhighlight> |
||
Yet another (undocumented) option, using (not delayed) variable expansion as long as it is undefined. This works because undefined variables result to blank line when expanded using <code>%</code>. |
|||
Since comment lines are skipped entirely by the parser multi-line comments aren't possible even with line continuation. |
|||
<syntaxhighlight lang="dos">% this works as long as you have no variable named exactly like this sentence. %</syntaxhighlight> |
|||
Since comment lines are skipped entirely by the parser, multi-line comments aren't possible even with line continuation. |
|||
=={{header|BBC BASIC}}== |
=={{header|BBC BASIC}}== |
||
< |
<syntaxhighlight lang="bbcbasic"> REM This is a comment which is ignored by the compiler |
||
*| This is a comment which is compiled but ignored at run time</ |
*| This is a comment which is compiled but ignored at run time</syntaxhighlight> |
||
=={{header|bc}}== |
=={{header|bc}}== |
||
< |
<syntaxhighlight lang="bc">/* This is a comment. */ |
||
2 + /* Comment between tokens. */ 3 |
2 + /* Comment between tokens. */ 3 |
||
Line 150: | Line 490: | ||
* of the comment are only for style. You must not nest a comment |
* of the comment are only for style. You must not nest a comment |
||
* inside another comment; the first asterisk-slash ends the comment. |
* inside another comment; the first asterisk-slash ends the comment. |
||
*/</ |
*/</syntaxhighlight> |
||
---- |
---- |
||
Line 156: | Line 496: | ||
{{works with|OpenBSD bc}} |
{{works with|OpenBSD bc}} |
||
< |
<syntaxhighlight lang="bc">#!/usr/bin/bc |
||
# This form of comment is an extension, not part of standard bc. |
# This form of comment is an extension, not part of standard bc. |
||
Line 166: | Line 506: | ||
a = 1 # The newline is not part of the comment. |
a = 1 # The newline is not part of the comment. |
||
b = 2 # So this line is a different statement.</ |
b = 2 # So this line is a different statement.</syntaxhighlight> |
||
=={{header|Beef}}== |
|||
<syntaxhighlight lang="csharp">//This is a comment. |
|||
//This is another comment. |
|||
/* This is also a comment. */ |
|||
/* This is a |
|||
multi-line |
|||
comment */ |
|||
</syntaxhighlight> |
|||
The IDE allows for documenting types and methods with /// or /** */ (which one of these you use doesn’t matter). Autocomplete suggestions, as well as prompts while calling/using the documented types or functions, will display their documentation. |
|||
<syntaxhighlight lang="csharp">static |
|||
{ |
|||
/// Must be placed directly above the method, including attributes. |
|||
/// Using multiple lines like this is also fine. Both will be recognized. |
|||
[Optimize] |
|||
public static void DoAThing() {} |
|||
/// Documentation also works for types. |
|||
struct SomeStruct |
|||
{ |
|||
/** |
|||
* Multiline comment with two ** at the start works in the same way. |
|||
*/ |
|||
void PrivateMethod() {} |
|||
} |
|||
/** |
|||
* If you have a really long explainer here, you may not actually want to show that in autcompletion prompts. |
|||
* @brief Allows you to select only this line to be shown. |
|||
* |
|||
* @param a This is shown when writing a call to this function and placing parameter "a". |
|||
* @param b For the second argument, the documentation for b (this!) will show up instead. |
|||
*/ |
|||
public static void DoAnotherThing(int a, int b) {} |
|||
} |
|||
</syntaxhighlight> |
|||
=={{header|Befunge}}== |
=={{header|Befunge}}== |
||
Line 175: | Line 556: | ||
{{works with|Befunge|93}} |
{{works with|Befunge|93}} |
||
< |
<syntaxhighlight lang="befunge">& read a number 2+ add two .@ display result and exit |
||
^- inline comments -^ <-^- other comments</ |
^- inline comments -^ <-^- other comments</syntaxhighlight> |
||
{{works with|Befunge|98}} |
{{works with|Befunge|98}} |
||
< |
<syntaxhighlight lang="befunge">&;read a number;2+;add two;.@;display result and exit; |
||
^- inline comments -^ <-^- other comments |
^- inline comments -^ <-^- other comments |
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
;completely isolated comment block for the paranoid; |
;completely isolated comment block for the paranoid; |
||
;(almost - you can still skip into it.) ; |
;(almost - you can still skip into it.) ; |
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</ |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</syntaxhighlight> |
||
=={{header|Binary Lambda Calculus}}== |
|||
BLC has no notion of comments, but since input is considered part of the program, one can always ignore the remainder of input, which can thus be arbitrary. Of course one can have comments in any language that translates to BLC, as discussed in https://rosettacode.org/wiki/Documentation#Binary_Lambda_Calculus |
|||
=={{header|Blast}}== |
=={{header|Blast}}== |
||
< |
<syntaxhighlight lang="blast"># A hash symbol at the beginning of a line marks the line as a comment |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header| |
=={{header|BQN}}== |
||
<syntaxhighlight lang="bqn"># This is a comment</syntaxhighlight> |
|||
=={{header|Bracmat}}== |
|||
<lang bf>This is a comment</lang> |
|||
Bracmat uses curly braces as comment delimiters. Curly braces inside comments must be balanced. Comments are so much ignored when source code is read, that they do not reappear in listings created by the built-in <code>lst$</code> function, an otherwise very useful function to autoindent your code. |
|||
=={{header|Brainf***}}== |
|||
Most ASCII characters may be used for comments; only the eight characters "+-<>[],." are Brainf*** commands. Extra care must be used when using punctuation, particularly the comma or period. These are I/O operators and are actually commands rather than comments, and are instead compiled into the program if used and may have to be "debugged" and removed if you forget this issue. |
|||
<syntaxhighlight lang="bf">This is a comment</syntaxhighlight> |
|||
Most ASCII characters may be used for comments; only the eight characters "+-<>[],." are Brainf*** commands. Extra care must be used when using punctuation, particularly the comma or period. These are I/O operators and are actually commands rather than comments, and are instead compiled into the program if used and may have to be "debugged" and removed if you forget this issue. Another workaround for this issue is to tactically place the comment inside a "[]" loop which can never be entered (The loop will only be encountered when the active memory cell value is 0). |
|||
=={{header|Brat}}== |
=={{header|Brat}}== |
||
< |
<syntaxhighlight lang="brat"># Single line comment |
||
#* Multi |
#* Multi |
||
Line |
Line |
||
Comment *#</ |
Comment *#</syntaxhighlight> |
||
=={{header|Bruijn}}== |
|||
Bruijn does not have multi-line comments. |
|||
<syntaxhighlight lang="bruijn"># This is a comment</syntaxhighlight> |
|||
=={{header|Brlcad}}== |
=={{header|Brlcad}}== |
||
< |
<syntaxhighlight lang="brlcad"> |
||
# Comments in mget scripts are prefixed with a hash symbol |
# Comments in mget scripts are prefixed with a hash symbol |
||
ls # comments may appear at the end of a line |
ls # comments may appear at the end of a line |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Burlesque}}== |
|||
Burlesque does NOT have comments. However, you can comment code by pushing a string and popping it immediately. |
|||
<syntaxhighlight lang="burlesque"> |
|||
"I'm sort of a comment"vv |
|||
</syntaxhighlight> |
|||
Since strings are multi-line strings: |
|||
<syntaxhighlight lang="burlesque"> |
|||
"I'm a |
|||
very long comment spanning |
|||
over several lines"vv |
|||
</syntaxhighlight> |
|||
=={{header|C}}== |
=={{header|C}}== |
||
< |
<syntaxhighlight lang="c">/* This is a comment. */ |
||
/* So is this |
/* So is this |
||
multiline comment. |
multiline comment. |
||
*/</ |
*/</syntaxhighlight> |
||
The comment starts at the <tt>/*</tt>, and ends at the <tt>*/</tt>. A comment may be used between any tokens. It cannot be used inside tokens, that is, given the code |
The comment starts at the <tt>/*</tt>, and ends at the <tt>*/</tt>. A comment may be used between any tokens. It cannot be used inside tokens, that is, given the code |
||
< |
<syntaxhighlight lang="c">struct charisma {}; |
||
void f(char/* comment */isma) {}</ |
void f(char/* comment */isma) {}</syntaxhighlight> |
||
the function takes an argument of type char, named isma, not an unnamed argument of type charisma. |
the function takes an argument of type char, named isma, not an unnamed argument of type charisma. |
||
Comments cannot be nested; that is, if you write |
Comments cannot be nested; that is, if you write |
||
< |
<syntaxhighlight lang="c">/* some comment /* trying to nest some other comment */ inside */</syntaxhighlight> |
||
the comment ends at the first <tt>*/</tt>, and <tt>inside */</tt> is again interpreted as source code (almost certainly causing a compile error). Some compilers have the option to allow nested comments, but this is not a standard feature. |
the comment ends at the first <tt>*/</tt>, and <tt>inside */</tt> is again interpreted as source code (almost certainly causing a compile error). Some compilers have the option to allow nested comments, but this is not a standard feature. |
||
Conditional compilation also can be used to make the compiler ignore some text: |
Conditional compilation also can be used to make the compiler ignore some text: |
||
< |
<syntaxhighlight lang="c">#if 0 |
||
While technically not a comment, this is also ignored by the compiler |
While technically not a comment, this is also ignored by the compiler |
||
#endif</ |
#endif</syntaxhighlight> |
||
The trick is that 0 is always false, therefore the text between <tt>#if 0</tt> and <tt>#endif</tt> is never compiled. While this should never be used for actual comments, it's an easy way to comment out some code, especially because it doesn't interfere with normal (documentation) comments. |
The trick is that 0 is always false, therefore the text between <tt>#if 0</tt> and <tt>#endif</tt> is never compiled. While this should never be used for actual comments, it's an easy way to comment out some code, especially because it doesn't interfere with normal (documentation) comments. |
||
Conditional compile "comments" can be nested: |
Conditional compile "comments" can be nested: |
||
< |
<syntaxhighlight lang="c">#ifdef UNDEFINED |
||
This is not compiled. |
This is not compiled. |
||
#if 0 |
#if 0 |
||
Line 238: | Line 648: | ||
#endif |
#endif |
||
And this still is not compiled. |
And this still is not compiled. |
||
#endif</ |
#endif</syntaxhighlight> |
||
{{works with|ANSI}} |
{{works with|ANSI}} |
||
Even though the compiler doesn't see '''#if 0''' text, the preprocessor does. Therefore some minimal rules still have to be followed. For example, the following code is ''not'' valid: |
Even though the compiler doesn't see '''#if 0''' text, the preprocessor does. Therefore some minimal rules still have to be followed. For example, the following code is ''not'' valid: |
||
< |
<syntaxhighlight lang="c">#if 0 |
||
This isn't valid. |
This isn't valid. |
||
#endif</ |
#endif</syntaxhighlight> |
||
That's because the preprocessor will interpret the apostrophe as beginning of a character constant, and will complain because that character constant isn't terminated with another apostrophe. |
That's because the preprocessor will interpret the apostrophe as beginning of a character constant, and will complain because that character constant isn't terminated with another apostrophe. |
||
Line 251: | Line 661: | ||
{{works with|C99}} |
{{works with|C99}} |
||
< |
<syntaxhighlight lang="c">// C++ single-line comments were adopted in the C99 standard.</syntaxhighlight> |
||
=={{header|C sharp|C#}}== |
|||
<syntaxhighlight lang="csharp">//This is a comment. |
|||
//This is other comment. |
|||
/* This is a comment too. */ |
|||
/* This is a |
|||
multi-line |
|||
comment */</syntaxhighlight> |
|||
=={{header|C++}}== |
=={{header|C++}}== |
||
Line 257: | Line 678: | ||
Single line C++-style comments |
Single line C++-style comments |
||
<lang |
<syntaxhighlight lang="cpp">// This is a comment</syntaxhighlight> |
||
C++-style comments start with <tt>//</tt> and reach up to, but not including, the end of line (more exactly, up to the next unescaped newline). While formally, C++-style comments cannot be nested either, in practice they can: |
C++-style comments start with <tt>//</tt> and reach up to, but not including, the end of line (more exactly, up to the next unescaped newline). While formally, C++-style comments cannot be nested either, in practice they can: |
||
< |
<syntaxhighlight lang="cpp">// This is a valid comment // with a "nested" comment</syntaxhighlight> |
||
That's because starting with the first <tt>//</tt> everything in the line is ignored, including the second <tt>//</tt>. |
That's because starting with the first <tt>//</tt> everything in the line is ignored, including the second <tt>//</tt>. |
||
The fact that the newline is ''not'' part of the comment is important for multi-line macro definitions. It means that in the code |
The fact that the newline is ''not'' part of the comment is important for multi-line macro definitions. It means that in the code |
||
< |
<syntaxhighlight lang="cpp">#define FOO \ |
||
(macro text) // comment |
(macro text) // comment |
||
(no more macro text)</ |
(no more macro text)</syntaxhighlight> |
||
the line <tt>(no more macro text)</tt> is ''not'' part of the macro definition. Also escaping the line break at the end of the comment with '\' doesn't help, because that would make the third line part of the ''comment'' instead. Comments inside macros therefore have to be C-style. |
the line <tt>(no more macro text)</tt> is ''not'' part of the macro definition. Also escaping the line break at the end of the comment with '\' doesn't help, because that would make the third line part of the ''comment'' instead. Comments inside macros therefore have to be C-style. |
||
=={{header| |
=={{header|Chapel}}== |
||
<syntaxhighlight lang="chapel">// single line |
|||
/* multi |
|||
<lang csharp>//This is a comment. |
|||
line */</syntaxhighlight> |
|||
//This is other comment. |
|||
/* This is a comment too. */ |
|||
/* This is a |
|||
multi-line |
|||
comment */</lang> |
|||
=={{header|Chef}}== |
=={{header|Chef}}== |
||
< |
<syntaxhighlight lang="chef">Comment Stew. |
||
This is a comment. |
This is a comment. |
||
Line 293: | Line 710: | ||
Methods. |
Methods. |
||
SingleWordCommentTwo until SingleWordCommentOned. |
SingleWordCommentTwo until SingleWordCommentOned. |
||
Methods.</ |
Methods.</syntaxhighlight> |
||
=={{header|ChucK}}== |
|||
<syntaxhighlight lang="chuck"> |
|||
<-- Not common |
|||
// Usual comment |
|||
</syntaxhighlight> |
|||
=={{header|Clean}}== |
=={{header|Clean}}== |
||
Clean comments are similar to C++. |
Clean comments are similar to C++. |
||
< |
<syntaxhighlight lang="clean">Start = /* This is a multi- |
||
line comment */ 17 // This is a single-line comment</ |
line comment */ 17 // This is a single-line comment</syntaxhighlight> |
||
In contrast to C++ comments can be nested. |
In contrast to C++ comments can be nested. |
||
< |
<syntaxhighlight lang="clean">Start = /* This is a comment /* Nested comment */ still a comment */ 17</syntaxhighlight> |
||
=={{header|Clojure}}== |
=={{header|Clojure}}== |
||
Line 306: | Line 729: | ||
Anything from a semicolon to the end of a line is a comment. |
Anything from a semicolon to the end of a line is a comment. |
||
< |
<syntaxhighlight lang="lisp">;; This is a comment |
||
(defn foo [] |
(defn foo [] |
||
123) ; also a comment</ |
123) ; also a comment</syntaxhighlight> |
||
The <code>(comment)</code> macro will prevent a form from being evaluated, returning <code>nil</code> no matter what is contained in the comment. However the forms inside the <code>comment</code> form must be properly parseable (parentheses balanced, etc.) or an exception will be thrown. |
The <code>(comment)</code> macro will prevent a form from being evaluated, returning <code>nil</code> no matter what is contained in the comment. However the forms inside the <code>comment</code> form must be properly parseable (parentheses balanced, etc.) or an exception will be thrown. |
||
< |
<syntaxhighlight lang="lisp">(comment (println (foo)) "bar" :baz 123 (System/exit 0)) ;; does nothing, returns nil</syntaxhighlight> |
||
Finally, the <code>#_</code> reader macro will cause a form to be ignored by the reader. Unlike <code>(comment)</code>, this does not return <code>nil</code>; the surrounding code is evaluated as though the ignored form isn't even there. |
Finally, the <code>#_</code> reader macro will cause a form to be ignored by the reader. Unlike <code>(comment)</code>, this does not return <code>nil</code>; the surrounding code is evaluated as though the ignored form isn't even there. |
||
< |
<syntaxhighlight lang="lisp">(+ 1 (comment "foo") 3) ;; Throws an exception, because it tries to add nil to an integer |
||
(+ 1 #_"foo" 3) ;; Returns 4</ |
(+ 1 #_"foo" 3) ;; Returns 4</syntaxhighlight> |
||
=={{header|CMake}}== |
|||
Line comments use the common <code>#</code> syntax: |
|||
<syntaxhighlight lang="cmake"># A single-line comment</syntaxhighlight> |
|||
Multi-line comments use a Lua-like square-bracket syntax. |
|||
<syntaxhighlight lang="cmake"> |
|||
#[[A multi-line |
|||
comment ]] |
|||
#[==[A multi-line comment |
|||
with [[nested brackets]]. ]==]</syntaxhighlight> |
|||
The number of equals signs (<code>=</code>) in the opening bracket determines the number expected in the closing bracket. |
|||
=={{header|COBOL}}== |
|||
=== Fixed format === |
|||
<syntaxhighlight lang="cobol"> * an asterisk in 7th column comments the line out</syntaxhighlight> |
|||
A D in the 7th column indicates a debugging line which is treated like a comment unless a compiler flag is set. |
|||
<syntaxhighlight lang="cobol"> D DISPLAY "Debug"</syntaxhighlight> |
|||
=== Free format === |
|||
<syntaxhighlight lang="cobol">*> This comment syntax was defined (with free format code) in COBOL 2002.</syntaxhighlight> |
|||
{{works with|GnuCOBOL}} |
|||
This indicates a debugging line like above, but if it is used in fixed format files, it must be in the 8th column or beyond. ''Not necessarily.'' GnuCOBOL also supports D as an indicator in column 7, the >>D format works (more by trickery than spec) if the angle brackets start in column 5, the D ending up in column 7. The >>D debug marker can then be both fixed and free form compatible. |
|||
<syntaxhighlight lang="cobol">>>D DISPLAY "Debug"</syntaxhighlight> |
|||
=== <code>NOTE</code> statement === |
|||
{{works with|OS/VS COBOL}} |
|||
This statement causes everything following it up to the next separator period to be treated as a comment. This statement was deleted in COBOL-74. |
|||
<syntaxhighlight lang="cobol"> NOTE this paragraph is |
|||
commented out and ignored |
|||
.</syntaxhighlight> |
|||
=== <code>REMARKS</code> and other statements === |
|||
{{works with|GnuCOBOL}} |
|||
There are quite a few <code>IDENTIFICATION DIVISION</code> obsolete and extension reserved words that will work in GnuCOBOL 2. |
|||
<syntaxhighlight lang="cobol"> |
|||
IDENTIFICATION DIVISION. |
|||
PROGRAM-ID. program. |
|||
AUTHOR. Rest of line ignored. |
|||
REMARKS. Rest of line ignored. |
|||
REMARKS. More remarks. |
|||
SECURITY. line ignored. |
|||
INSTALLATION. line ignored. |
|||
DATE-WRITTEN. same, human readable dates are allowed for instance |
|||
DATE-COMPILED. same. |
|||
DATE-MODIFIED. this one is handy when auto-stamped by an editor. |
|||
</syntaxhighlight> Those lines can occur multiple times each within the IDENTIFICATION DIVISION. There can be many AUTHORs, SECURITY notes, etc. These words are also supported by other COBOL dialects, but may have different rules on order, multiples allowed of if full stop periods are required (or allowed) before the end of line. |
|||
=={{header|CoffeeScript}}== |
=={{header|CoffeeScript}}== |
||
< |
<syntaxhighlight lang="coffeescript"># one line comment |
||
### multi |
### multi |
||
line |
line |
||
comment ###</ |
comment ###</syntaxhighlight> |
||
=={{header|ColdFusion}}== |
=={{header|ColdFusion}}== |
||
In tags: |
In tags: |
||
< |
<syntaxhighlight lang="cfm">As ColdFusion's grammar is based around HTML syntax, commenting is similar to HTML. |
||
< |
<!--- This is a comment. Nothing in this tag can be seen by the end user. |
||
Note the three-or-greater dashes to open and close the tag. ---> |
Note the three-or-greater dashes to open and close the tag. ---> |
||
< |
<!-- This is an HTML comment. Any HTML between the opening and closing of the tag will be ignored, but any ColdFusion code will still run. |
||
Note that in the popular FuseBox framework for ColdFusion, the circuit.xml files require that you use this style of comment. --></ |
Note that in the popular FuseBox framework for ColdFusion, the circuit.xml files require that you use this style of comment. --></syntaxhighlight> |
||
In script: |
In script: |
||
< |
<syntaxhighlight lang="cfm">/* This is a comment */ |
||
// This is also a comment</ |
// This is also a comment</syntaxhighlight> |
||
=={{header|Common Lisp}}== |
=={{header|Common Lisp}}== |
||
Line 345: | Line 822: | ||
In a common convention, header comments are prefaced with four semicolons, top-level (function level) comments use three, comments for sections of code use two, and margin comments use one. |
In a common convention, header comments are prefaced with four semicolons, top-level (function level) comments use three, comments for sections of code use two, and margin comments use one. |
||
< |
<syntaxhighlight lang="lisp">;;;; This code implements the foo and bar functions |
||
;;; The foo function calls bar on the first argument and multiplies the result by the second. |
;;; The foo function calls bar on the first argument and multiplies the result by the second. |
||
Line 356: | Line 833: | ||
;;; The bar function simply adds 3 to the argument |
;;; The bar function simply adds 3 to the argument |
||
(defun bar (n) |
(defun bar (n) |
||
(+ n 3))</ |
(+ n 3))</syntaxhighlight> |
||
However, comments should not be used for inline documentation, as most defining constructs permit a documentation string (which is then available at runtime). <!-- It would be better to make the above example not do this, instead of showing bad style --> |
However, comments should not be used for inline documentation, as most defining constructs permit a documentation string (which is then available at runtime). <!-- It would be better to make the above example not do this, instead of showing bad style --> |
||
< |
<syntaxhighlight lang="lisp">(defun bar (n) |
||
"Add 3 to the argument." |
"Add 3 to the argument." |
||
(+ n 3)) |
(+ n 3)) |
||
Line 366: | Line 843: | ||
(defclass button (widget) |
(defclass button (widget) |
||
(label action) |
(label action) |
||
(:documentation "This is a push-button widget."))</ |
(:documentation "This is a push-button widget."))</syntaxhighlight> |
||
=={{header|Component Pascal}}== |
|||
<syntaxhighlight lang="oberon2"> |
|||
(* Comments (* can nest *) |
|||
and they can span multiple lines. |
|||
*) |
|||
</syntaxhighlight> |
|||
=={{header|Crystal}}== |
|||
<syntaxhighlight lang="ruby"># currently, Crystal only supports single-line comments |
|||
# This is a doc comment. Any line *directly* above (no blank lines) a module, class, or method is considered a doc comment |
|||
# Doc comments are used to generate documentation with `crystal docs` |
|||
class Foo |
|||
end</syntaxhighlight> |
|||
=={{header|D}}== |
=={{header|D}}== |
||
<syntaxhighlight lang="d">void main() { |
|||
// A single line comment. |
|||
/* This is a simple C-style comment that can't be nested. |
|||
Comments mostly work similar to C. Newlines are irrelevant. |
|||
Comments mostly work similar to C, newlines are irrelevant. |
|||
<lang d>/* This is a simple |
|||
*/ |
|||
// this also is</lang> |
|||
This type of comments can be nested. |
|||
<lang d>/+ Nestable comment |
|||
/+ See? |
|||
+/ |
|||
+/ |
|||
Yay! I'm code!</lang> |
|||
/+ This is a nestable comment |
|||
=== Documentation Comments === |
|||
/+ See? |
|||
+/ |
|||
+/ |
|||
/// Documentation single line comment. |
|||
D also has a built-in tool for generating documentation from |
|||
comments ([http://www.digitalmars.com/d/2.0/ddoc.html DDOC]). |
|||
/** |
|||
Documentation comments look like this: |
|||
Simple C-style documentation comment. |
|||
*/ |
|||
/** I'm multi- |
|||
line documentation. */ |
|||
/++ |
/++ |
||
Nestable documenttion comment. |
|||
/++ can be nested +/ +/ |
|||
+/ |
|||
</lang> |
|||
}</syntaxhighlight> |
|||
DDOC is designed to read like natural language. For example, this |
|||
is a valid DDOC comment: |
|||
=={{header|Dart}}== |
|||
<lang d> |
|||
/***************************************** |
|||
<syntaxhighlight lang="dart">// This is a single line comment, which lasts until the end of the line. The Dart linter prefers this one. |
|||
* This function solves world hunger. |
|||
* Examples: |
|||
/* This is also a valid single line comment. Unlike the first one, this one terminates after one of these -> */ |
|||
* ---------------------------------------- |
|||
* feed_world (earth); |
|||
/* |
|||
* ---------------------------------------- |
|||
You can use the syntax above to make multi line comments as well. |
|||
* Date: May 4, 2011 |
|||
Like this! |
|||
* Bugs: Does not solve world thirst. |
|||
*/ |
|||
* See_Also: |
|||
* SoylentGreen |
|||
/// These are doc comments. You can use dartdoc to generate doc pages for your classes with these. |
|||
* Authors: J. Random Hacker. */ |
|||
/// |
|||
</lang> |
|||
/// Formatting [variable] and [function] names like so allows dartdoc to link to the documentation for those entities. |
|||
</syntaxhighlight> |
|||
=={{header|dc}}== |
=={{header|dc}}== |
||
There is no comment syntax in POSIX dc. The convention is to make a string on the stack and move it to an unused register; a no-op. |
There is no comment syntax in POSIX dc. The convention is to make a string on the stack and move it to an unused register; a no-op. |
||
< |
<syntaxhighlight lang="dc">[Making and discarding a string acts like a comment] sz</syntaxhighlight> |
||
GNU dc added the comment syntax of many other scripting languages. |
GNU dc added the comment syntax of many other scripting languages. |
||
< |
<syntaxhighlight lang="dc"># remainder of line is a comment</syntaxhighlight> |
||
=={{header|Delphi}}== |
|||
:''See also [[Comments#Pascal|Pascal]]'' |
|||
In addition to Pascal, Delphi also allows C++ style single line comments: |
|||
<syntaxhighlight lang="delphi">// single line comment</syntaxhighlight> |
|||
=={{header|Deluge}}== |
=={{header|Deluge}}== |
||
Line 418: | Line 916: | ||
Comments are only allowed in places such as "on load" scripts. You cannot put them in form or view definitions. |
Comments are only allowed in places such as "on load" scripts. You cannot put them in form or view definitions. |
||
<lang |
<syntaxhighlight lang="deluge">// single line comment</syntaxhighlight> |
||
=={{header| |
=={{header|Dragon}}== |
||
<syntaxhighlight lang="dragon">// This is a comment </syntaxhighlight> |
|||
:''See also [[Comments#Pascal|Pascal]]'' |
|||
<syntaxhighlight lang="dragon">/* |
|||
In addition, Delphi also allows C++ style single line comments: |
|||
This is |
|||
<lang delphi>// single line comment</lang> |
|||
a multiple |
|||
line comment. |
|||
*/</syntaxhighlight> |
|||
<syntaxhighlight lang="dragon"> |
|||
showln "Hello " /* This is an inline comment */ "world" |
|||
</syntaxhighlight> |
|||
=={{header|DWScript}}== |
|||
<syntaxhighlight lang="delphi">(* This is a comment. |
|||
It may extend across multiple lines. *) |
|||
{ Alternatively curly braces |
|||
can be used. } |
|||
/* C-style multi-line comments |
|||
are supported */ |
|||
// and single-line C++ style comments too</syntaxhighlight> |
|||
=={{header|Dyalect}}== |
|||
<syntaxhighlight lang="dyalect">/* This is a |
|||
multi-line comment */ |
|||
//This is a single-line comment</syntaxhighlight> |
|||
=={{header|Dylan}}== |
|||
<syntaxhighlight lang="dylan">// This is a comment |
|||
/* |
|||
This is a comment |
|||
that spans multiple |
|||
lines |
|||
*/</syntaxhighlight> |
|||
=={{header|Déjà Vu}}== |
|||
<syntaxhighlight lang="dejavu">#this is a comment |
|||
!print "this is not a comment, obviously" #this is a comment as well</syntaxhighlight> |
|||
=={{header|E}}== |
=={{header|E}}== |
||
< |
<syntaxhighlight lang="e"># This is a regular comment. |
||
? "This is an Updoc comment, which |
? "This is an Updoc comment, which |
||
> is an executable example or test case.".split(" ") |
> is an executable example or test case.".split(" ") |
||
# value: ["This", "is", "an", "Updoc", "comment,", "which |
# value: ["This", "is", "an", "Updoc", "comment,", "which |
||
# is", "an", "executable", "example", "or", "test", "case."]</ |
# is", "an", "executable", "example", "or", "test", "case."]</syntaxhighlight> |
||
All comments span to the end of the line; there are no paired-delimiter comment syntaxes. “<code>#</code>” begins a comment anywhere outside of quotes; “<code>?</code>” and “<code>></code>” begin comments only if they are at the beginning of a line (except for whitespace), because those characters are also used for infix operators. |
All comments span to the end of the line; there are no paired-delimiter comment syntaxes. “<code>#</code>” begins a comment anywhere outside of quotes; “<code>?</code>” and “<code>></code>” begin comments only if they are at the beginning of a line (except for whitespace), because those characters are also used for infix operators. |
||
In Updoc, “<code>?</code>” indicates the beginning of a program fragment, “<code>></code>” the continuation of one, and “<code>#</code>” begins the expected output from its evaluation; “<code>??</code>” indicates special directives. |
In Updoc, “<code>?</code>” indicates the beginning of a program fragment, “<code>></code>” the continuation of one, and “<code>#</code>” begins the expected output from its evaluation; “<code>??</code>” indicates special directives. |
||
=={{header|EasyLang}}== |
|||
<syntaxhighlight lang="text"># This is a comment</syntaxhighlight> |
|||
=={{header|EchoLisp}}== |
|||
<syntaxhighlight lang="lisp"> |
|||
666 ; this is an end-of-line comment |
|||
#| |
|||
This is a multi-line comment |
|||
Nesting is not allowed |
|||
|# |
|||
;; The (info <name> [<string>)] function associates a symbol and a comment |
|||
;; These info strings are saved in permanent memory (local storage) |
|||
;; Unicode characters may be used, as everywhere in the language |
|||
(define mynumber 666) → mynumber |
|||
(info 'mynumber "👀 Symbols may be commented with an information string 👺") |
|||
(info 'mynumber) → displays the above inside the 'info' field. |
|||
</syntaxhighlight> |
|||
=={{header|ECL}}== |
|||
Single-line comments must begin with // |
|||
<syntaxhighlight lang="ecl">// this is a one-line comment </syntaxhighlight> |
|||
Block comments must be delimited with /* and */ |
|||
<syntaxhighlight lang="ecl"> /* this is a block comment - the terminator can be on the same line |
|||
or any succeeding line – everything in between is ignored */</syntaxhighlight> |
|||
=={{header|Ecstasy}}== |
|||
Comments in Ecstasy follow the two forms used by most C-family languages: |
|||
<syntaxhighlight lang="java"> |
|||
/* |
|||
* This is a multi-line comment. |
|||
*/ |
|||
Int i = 0; // This is an end-of-line comment |
|||
</syntaxhighlight> |
|||
=={{header|ed}}== |
|||
<syntaxhighlight lang="sed"> |
|||
# A single-line comment. |
|||
# The only type of comment, really. |
|||
# No block comments in ed |
|||
</syntaxhighlight> |
|||
=={{header|EDSAC order code}}== |
|||
EDSAC programs were handwritten on "programme sheets" designed for the purpose. The programmer, or a computer operator, then copied the "orders" (instructions) to punched tape for input to the machine. Programme sheets had a column for "notes" (comments), but these were not copied to the tape. |
|||
Modern simulators, however, accept square brackets as comment delimiters. |
|||
<syntaxhighlight lang="edsac">[This is a comment] |
|||
[ |
|||
And so |
|||
is |
|||
this |
|||
] |
|||
[But in 1949 they wouldn't have been]</syntaxhighlight> |
|||
=={{header|EGL}}== |
|||
:''See [[Comments#Java|Java]]'' |
|||
=={{header|Eiffel}}== |
|||
<syntaxhighlight lang="eiffel">-- inline comment, continues until new line</syntaxhighlight> |
|||
=={{header|Ela}}== |
=={{header|Ela}}== |
||
< |
<syntaxhighlight lang="ela">//single line comment |
||
/*multiple line |
/*multiple line |
||
comment*/</ |
comment*/</syntaxhighlight> |
||
=={{header|Elena}}== |
|||
<syntaxhighlight lang="elena">//single line comment |
|||
/*multiple line |
|||
comment*/</syntaxhighlight> |
|||
=={{header|Elixir}}== |
|||
Elixir does not have multiple line comments. |
|||
<syntaxhighlight lang="elixir"> |
|||
# single line comment |
|||
</syntaxhighlight> |
|||
=={{header|Elm}}== |
|||
<syntaxhighlight lang="elm"> |
|||
-- a single line comment |
|||
{- a multiline comment |
|||
{- can be nested -} |
|||
-} |
|||
</syntaxhighlight> |
|||
=={{header|Emacs Lisp}}== |
=={{header|Emacs Lisp}}== |
||
A comment is started by <code>;</code> and reaches to the end of the line. |
A comment is started by <code>;</code> and reaches to the end of the line. |
||
<lang |
<syntaxhighlight lang="lisp">; This is a comment</syntaxhighlight> |
||
There are some coding conventions for <code>;;</code> align to indentation, <code>;;;</code> sections, etc, |
|||
: [http://www.gnu.org/software/emacs/manual/html_node/elisp/Comment-Tips.html http://www.gnu.org/software/emacs/manual/html_node/elisp/Comment-Tips.html] |
|||
Another way to add comments is to use strings at places where the result of an expression is ignored, since they simply evaluate to themselves without any effect. Note that strings can be multi-line: |
Another way to add comments is to use strings at places where the result of an expression is ignored, since they simply evaluate to themselves without any effect. Note that strings can be multi-line: |
||
< |
<syntaxhighlight lang="lisp">"This is effectively a comment, |
||
if used at a place where the result is ignored"</ |
if used at a place where the result is ignored"</syntaxhighlight> |
||
Note that strings at the beginning of function definitions are interpreted as documentation strings for the function (i.e. Emacs will display them if asked for help about the function), e.g. |
Note that strings at the beginning of function definitions are interpreted as documentation strings for the function (i.e. Emacs will display them if asked for help about the function), e.g. |
||
< |
<syntaxhighlight lang="lisp">(defun subtract-second-from-first (x y) |
||
"This function subtracts its second argument from its first argument." |
"This function subtracts its second argument from its first argument." |
||
(- y x))</ |
(- y x))</syntaxhighlight> |
||
Due to this, it's debatable if the string at that place can be considered as comment. |
Due to this, it's debatable if the string at that place can be considered as comment. |
||
=={{header|EMal}}== |
|||
<syntaxhighlight lang="emal"> |
|||
# This is a line comment. |
|||
^|This is a single line block comment.|^ |
|||
^| This is |
|||
| a multi-line |
|||
| block comment. |
|||
|^ |
|||
^|This is a ^|nested|^ block comment.|^ |
|||
</syntaxhighlight> |
|||
=={{header|Erlang}}== |
=={{header|Erlang}}== |
||
< |
<syntaxhighlight lang="erlang">% Erlang comments begin with "%" and extend to the end of the line.</syntaxhighlight> |
||
=={{header|ERRE}}== |
|||
<syntaxhighlight lang="erre"> |
|||
! Standard ERRE comments begin with ! and extend to the end of the line |
|||
PRINT("this is code") ! comment after statement |
|||
</syntaxhighlight> |
|||
=={{header|Euphoria}}== |
=={{header|Euphoria}}== |
||
Single line comment: |
Single line comment: |
||
<lang |
<syntaxhighlight lang="euphoria">-- This is a comment</syntaxhighlight> |
||
Multiline C-style comment: |
Multiline C-style comment: |
||
<syntaxhighlight lang="euphoria">/* |
|||
<lang Euphoria>/* |
|||
This is a comment |
This is a comment |
||
*/</ |
*/</syntaxhighlight> |
||
{{works with|Euphoria|4.0.0}} |
{{works with|Euphoria|4.0.0}} |
||
=={{header|F_Sharp|F#}}== |
|||
F# accepts C++ type line comments and OCaml type block comments |
|||
<syntaxhighlight lang="fsharp">// this comments to the end of the line |
|||
(* this comments a region |
|||
which can be multi-line *)</syntaxhighlight> |
|||
=={{header|Factor}}== |
=={{header|Factor}}== |
||
< |
<syntaxhighlight lang="factor">! Comments starts with "! " |
||
#! Or with "#! " |
#! Or with "#! " |
||
! and last until the end of the line |
! and last until the end of the line |
||
</lang> |
|||
USE: multiline |
|||
=={{header|Fancy}}== |
|||
/* The multiline vocabulary implements |
|||
C-like multiline comments. */</syntaxhighlight> |
|||
<lang fancy># Comments starts with "#" |
|||
# and last until the end of the line |
|||
</lang> |
|||
=={{header|Falcon}}== |
=={{header|Falcon}}== |
||
Falcon supports C-language style single line and block comments. A single line comment begins with two slashes (//) and ends at the end of the line. A block comment begins with a slash followed by an asterisk, and terminates when an asterisk followed by a slash is met (/*...*/). |
Falcon supports C-language style single line and block comments. A single line comment begins with two slashes (//) and ends at the end of the line. A block comment begins with a slash followed by an asterisk, and terminates when an asterisk followed by a slash is met (/*...*/). |
||
< |
<syntaxhighlight lang="falcon"> |
||
/* Start comment block |
/* Start comment block |
||
My Life Story |
My Life Story |
||
Line 493: | Line 1,149: | ||
// set up my bank account total |
// set up my bank account total |
||
bank_account_total = 1000000 // Wish this was the case |
bank_account_total = 1000000 // Wish this was the case |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|FALSE}}== |
=={{header|FALSE}}== |
||
< |
<syntaxhighlight lang="false">{comments are in curly braces}</syntaxhighlight> |
||
=={{header|Fancy}}== |
|||
<syntaxhighlight lang="fancy"># Comments starts with "#" |
|||
# and last until the end of the line |
|||
</syntaxhighlight> |
|||
=={{header|Fennel}}== |
|||
<syntaxhighlight lang="fennel">; This is a single-line comment</syntaxhighlight> |
|||
=={{header|Fermat}}== |
|||
<syntaxhighlight lang="fermat">Function Foo(n) = |
|||
{Comments within a function are enclosed within curly brackets.} |
|||
{You can make multi-line comments |
|||
such as this one.} |
|||
n:=n^2 + 3n - 222; {Comments can go after a semicolon.} |
|||
n:=n+1; |
|||
n. |
|||
; comments between functions are preceded by semicolons, like this |
|||
Function Bar(n) = |
|||
2n-1.</syntaxhighlight> |
|||
=={{header|Fish}}== |
=={{header|Fish}}== |
||
Since ><> is a funge-like language, all characters not touched by the command pointer or modified by the <tt>p</tt> and <tt>g</tt> commands can be comments. |
Since ><> is a funge-like language, all characters not touched by the command pointer or modified by the <tt>p</tt> and <tt>g</tt> commands can be comments. |
||
Unlike Brainf***, unknown commands are not ignored by the compiler, they just raise an error. |
Unlike Brainf***, unknown commands are not ignored by the compiler, they just raise an error. |
||
< |
<syntaxhighlight lang="fish">v This is the Fish version of the Integer sequence task |
||
>0>:n1+v all comments here |
>0>:n1+v all comments here |
||
^o" "< still here |
^o" "< still here |
||
And of course here :)</ |
And of course here :)</syntaxhighlight> |
||
=={{header|Forth}}== |
=={{header|Forth}}== |
||
Standard Forth includes a number of ways to add comment text. As with everything in Forth, comment characters are actually words that control the compiler. |
Standard Forth includes a number of ways to add comment text. As with everything in Forth, comment characters are actually words that control the compiler. |
||
< |
<syntaxhighlight lang="forth">\ The backslash skips everything else on the line |
||
( The left paren skips everything up to the next right paren on the same line)</ |
( The left paren skips everything up to the next right paren on the same line)</syntaxhighlight> |
||
Traditionally, the paren comments are used for "stack effect" notation: |
Traditionally, the paren comments are used for "stack effect" notation: |
||
< |
<syntaxhighlight lang="forth">: myword ( a b -- c ) ...</syntaxhighlight> |
||
This comment means "myword takes two cells on the stack and leaves one". Sometimes, stack effect comment names give clues about the word's function: |
This comment means "myword takes two cells on the stack and leaves one". Sometimes, stack effect comment names give clues about the word's function: |
||
< |
<syntaxhighlight lang="forth">: add'em ( a b -- a+b ) + ; |
||
: strlen ( addr -- len ) count nip ;</ |
: strlen ( addr -- len ) count nip ;</syntaxhighlight> |
||
Some Forth systems implement other commenting words, such as these words from Win32Forth: |
Some Forth systems implement other commenting words, such as these words from Win32Forth: |
||
< |
<syntaxhighlight lang="forth">\s skips all remaining text in the file |
||
(( skips until the next double-paren, |
(( skips until the next double-paren, |
||
stretching across multiple lines )) |
stretching across multiple lines )) |
||
Line 530: | Line 1,209: | ||
enddoc |
enddoc |
||
/* C-style comment */ |
/* C-style comment */ |
||
(* Pascal-style comment *)</ |
(* Pascal-style comment *)</syntaxhighlight> |
||
=={{header|Fortran}}== |
=={{header|Fortran}}== |
||
Line 538: | Line 1,217: | ||
The first six columns in Fortran are traditionally reserved for labels and certain special characters. In particular the letter "C" in the first column indicates a comment: |
The first six columns in Fortran are traditionally reserved for labels and certain special characters. In particular the letter "C" in the first column indicates a comment: |
||
< |
<syntaxhighlight lang="fortran">C This would be some kind of comment |
||
C Usually one would avoid columns 2-6 even in a comment.</ |
C Usually one would avoid columns 2-6 even in a comment.</syntaxhighlight> |
||
Some Fortran compilers have the extension that comments starting with D are treated as non-comments if a special debugging flag is given at the compiler invocation. For example: |
Some Fortran compilers have the extension that comments starting with D are treated as non-comments if a special debugging flag is given at the compiler invocation. For example: |
||
< |
<syntaxhighlight lang="fortran">C If compiled in debugging mode, print the current value of I |
||
D PRINT *, I</ |
D PRINT *, I</syntaxhighlight> |
||
ISO Fortran 90 or later have an inline comment (!) syntax: |
ISO Fortran 90 or later have an inline comment (!) syntax: |
||
< |
<syntaxhighlight lang="fortran">real :: a = 0.0 ! initialize A to be zero</syntaxhighlight> |
||
In ISO Fortran 90 or later, "C in first column" comments are only allowed in the "fixed" source form familiar to FORTRAN 77 programmers. The "free" source form only has inline comments (! |
In ISO Fortran 90 or later, "C in first column" comments are only allowed in the "fixed" source form familiar to FORTRAN 77 programmers. The "free" source form only has inline comments (!). |
||
ISO Fortran 95 or later has an optional conditional compilation syntax. If present, it can be used (abused?) to (in effect) comment out blocks of code: |
ISO Fortran 95 or later has an optional conditional compilation syntax. If present, it can be used (abused?) to (in effect) comment out blocks of code: |
||
< |
<syntaxhighlight lang="fortran">?? if (.false.) then |
||
do while (oh_no) |
do while (oh_no) |
||
a = bad_news() |
a = bad_news() |
||
Line 560: | Line 1,239: | ||
c = gigo() |
c = gigo() |
||
end do |
end do |
||
?? end if</ |
?? end if</syntaxhighlight> |
||
=={{header| |
=={{header|FreeBASIC}}== |
||
<syntaxhighlight lang="freebasic">' FB 1.05.0 Win64 |
|||
F# accepts C++ type line comments and OCaml type block comments |
|||
<lang fsharp>// this comments to the end of the line |
|||
' This a single line comment |
|||
(* this comments a region |
|||
which can be multi-line *)</lang> |
|||
REM This is another way of writing a single line comment |
|||
/' |
|||
This is a |
|||
multi-line |
|||
comment |
|||
'/ |
|||
/' |
|||
Multi-line comments |
|||
/' |
|||
can also be nested |
|||
'/ |
|||
like this |
|||
'/</syntaxhighlight> |
|||
=={{header|Frink}}== |
|||
<syntaxhighlight lang="frink"> |
|||
// This is a single-line comment |
|||
/* This is a comment |
|||
that spans multiple lines |
|||
and so on. |
|||
*/ |
|||
</syntaxhighlight> |
|||
=={{header|Futhark}}== |
|||
<syntaxhighlight lang="futhark"> |
|||
-- Single-line comment |
|||
-- Multi-line |
|||
-- comment (yes, just several single-line comments). |
|||
</syntaxhighlight> |
|||
=={{header|FutureBasic}}== |
|||
<syntaxhighlight lang="futurebasic"> |
|||
// Single line comment |
|||
rem Single line comment |
|||
/* Single line comment */ |
|||
/* |
|||
Multiline |
|||
comment |
|||
*/ |
|||
</syntaxhighlight> |
|||
=={{header|FUZE BASIC}}== |
|||
<syntaxhighlight lang="qbasic">//Comment (No space required) |
|||
# Comment (Space required) |
|||
REM Comment (Space require) |
|||
PRINT "This is an inline comment."//Comment (No space required) |
|||
END</syntaxhighlight> |
|||
=={{header|Gambas}}== |
=={{header|Gambas}}== |
||
Line 572: | Line 1,303: | ||
In gambas, comments can be inserted by prefixing them with an apostrophe. The gambas interpreter will ignore the apostrophe and any other characters that follow it until the end of the line: |
In gambas, comments can be inserted by prefixing them with an apostrophe. The gambas interpreter will ignore the apostrophe and any other characters that follow it until the end of the line: |
||
< |
<syntaxhighlight lang="gambas"> |
||
' This whole line is a comment and is ignored by the gambas interpreter |
' This whole line is a comment and is ignored by the gambas interpreter |
||
print "Hello" ' Comments after an apostrophe are ignored |
print "Hello" ' Comments after an apostrophe are ignored |
||
'' A bold-style comment |
|||
</lang> |
|||
' TODO: To Do comment will appear in Task Bar |
|||
' FIXME: Fix Me comment will appear in Task Bar |
|||
' NOTE: Note commnet will appear in Task Bar |
|||
</syntaxhighlight> |
|||
=={{header|GAP}}== |
=={{header|GAP}}== |
||
< |
<syntaxhighlight lang="gap"># Comment (till end of line)</syntaxhighlight> |
||
=={{header|gecho}}== |
|||
<syntaxhighlight lang="gecho">( this is a test comment... o.O ) 1 2 + .</syntaxhighlight> |
|||
=={{header|Gema}}== |
=={{header|Gema}}== |
||
< |
<syntaxhighlight lang="gama">! comment starts with "!" and continues to end of line</syntaxhighlight> |
||
A shebang (#!) may be used as a comment in the first line of a file. |
A shebang (#!) may be used as a comment in the first line of a file. |
||
=={{header|Genie}}== |
|||
Genie allows comments in code in two different ways. |
|||
<syntaxhighlight lang="genie">// Comment continues until end of line |
|||
/* Comment lasts between delimiters */</syntaxhighlight> |
|||
Delimited comments cannot be nested. |
|||
=={{header|GML}}== |
=={{header|GML}}== |
||
single-line comment: |
single-line comment: |
||
< |
<syntaxhighlight lang="gml"> // comment starts with "//" and continues to the end of the line</syntaxhighlight> |
||
multi-line comment: |
multi-line comment: |
||
< |
<syntaxhighlight lang="gml"> /* a multi-line comment starts with slash-asterisk and, |
||
ends with asterisk-slash. |
ends with asterisk-slash. |
||
also note: |
also note: |
||
* A multi-line comment is ignored inside a string |
* A multi-line comment is ignored inside a string |
||
* A multi-line comment can be ended inside a line |
* A multi-line comment can be ended inside a line |
||
*/</ |
*/</syntaxhighlight> |
||
=={{header|gnuplot}}== |
|||
<syntaxhighlight lang="gnuplot"># this is a comment |
|||
# backslash continues \ |
|||
a comment to the next \ |
|||
line or lines</syntaxhighlight> |
|||
The way backslash continues a comment means that comments can't usefully be put within a multi-line function definition, |
|||
<syntaxhighlight lang="gnuplot"># this doesn't work |
|||
foo(n) = (n \ |
|||
+ 2 # no good \ |
|||
+ 3) |
|||
# behaves as if you wrote merely |
|||
foo(n) = (n+2</syntaxhighlight> |
|||
=={{header|Go}}== |
=={{header|Go}}== |
||
< |
<syntaxhighlight lang="go">// this is a single line comment |
||
/* this is |
/* this is |
||
a multi-line |
a multi-line |
||
block comment. |
block comment. |
||
/* It does not nest */</ |
/* It does not nest */</syntaxhighlight> |
||
=={{header|Golfscript}}== |
=={{header|Golfscript}}== |
||
<lang |
<syntaxhighlight lang="golfscript"># end of line comment</syntaxhighlight> |
||
=={{header|Gri}}== |
|||
<code>#</code> through to newline. |
|||
<syntaxhighlight lang="gri"># this is a comment |
|||
show 123 # this too is a comment</syntaxhighlight> |
|||
<code>//</code> works similarly but is reckoned the "old way" (as of Gri 2.12.23) |
|||
<syntaxhighlight lang="text">// this is a comment |
|||
show 123 // this too is a comment</syntaxhighlight> |
|||
Both forms can be used in input data files too. |
|||
=={{header|Groovy}}== |
=={{header|Groovy}}== |
||
Line 612: | Line 1,388: | ||
{{works with|GW-BASIC}} |
{{works with|GW-BASIC}} |
||
< |
<syntaxhighlight lang="gwbasic">100 REM Standard BASIC comments begin with "REM" (remark) and extend to the end of the line |
||
110 PRINT "this is code": REM comment after statement</ |
110 PRINT "this is code": REM comment after statement</syntaxhighlight> |
||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||
<syntaxhighlight lang="haskell">i code = True -- I am a comment. |
|||
<lang haskell>i code = True -- I am a comment. |
|||
{- I am also |
{- I am also |
||
Line 631: | Line 1,406: | ||
This is a Haddock documentation block comment |
This is a Haddock documentation block comment |
||
-} |
-} |
||
i code = True</ |
i code = True</syntaxhighlight> |
||
=={{header| |
=={{header|Haxe}}== |
||
< |
<syntaxhighlight lang="haxe">// Single line commment. |
||
/* |
/* |
||
Line 640: | Line 1,415: | ||
line |
line |
||
comment. |
comment. |
||
*/</ |
*/</syntaxhighlight> |
||
=={{header|HicEst}}== |
=={{header|HicEst}}== |
||
< |
<syntaxhighlight lang="hicest">! a comment starts with a "!" and ends at the end of the line</syntaxhighlight> |
||
=={{header|Hope}}== |
|||
<syntaxhighlight lang="hope">! All Hope comments begin with "!" and extend to the end of the line</syntaxhighlight> |
|||
=={{header|HTML}}== |
=={{header|HTML}}== |
||
< |
<syntaxhighlight lang="html5"><!-- Anything within these bracket tags is commented, single or multi-line. --></syntaxhighlight> |
||
=={{header|Icon}} and {{header|Unicon}}== |
=={{header|Icon}} and {{header|Unicon}}== |
||
Any text after "#" is a comment. |
Any text after "#" is a comment. |
||
< |
<syntaxhighlight lang="icon"># This is a comment |
||
procedure x(y,z) #: This is a comment and an IPL meta-comment for a procedure |
procedure x(y,z) #: This is a comment and an IPL meta-comment for a procedure |
||
</syntaxhighlight> |
|||
</lang> |
|||
The [[:Category:Icon_Programming_Library|The Icon Programming Library]] established conventions for commenting library additions and functions. This included both header block comments and meta comments on procedures within library files. |
The [[:Category:Icon_Programming_Library|The Icon Programming Library]] established conventions for commenting library additions and functions. This included both header block comments and meta comments on procedures within library files. |
||
Line 660: | Line 1,438: | ||
The comment character in IDL is the semicolon - everything starting with it and to the end of the line is a comment. Like this: |
The comment character in IDL is the semicolon - everything starting with it and to the end of the line is a comment. Like this: |
||
< |
<syntaxhighlight lang="idl">; The following computes the factorial of a number "n" |
||
fact = product(indgen( n )+1) ; where n should be an integer</ |
fact = product(indgen( n )+1) ; where n should be an integer</syntaxhighlight> |
||
=={{header|Inform 7}}== |
=={{header|Inform 7}}== |
||
< |
<syntaxhighlight lang="inform7">[This is a single-line comment.] |
||
[This is a |
[This is a |
||
multi-line comment.] |
multi-line comment.] |
||
[Comments can [be nested].]</ |
[Comments can [be nested].]</syntaxhighlight> |
||
=={{header|Insitux}}== |
|||
<syntaxhighlight lang="insitux"> |
|||
;this is a comment; and using semicolons here is fine |
|||
(+ 2 2) ;this is a comment |
|||
"this string will be ignored if in the top scope |
|||
which can also stretch across |
|||
multiple lines" |
|||
(do "if you're desperate, using do will make sure this string will not be returned also" |
|||
(+ 2 2)) |
|||
</syntaxhighlight> |
|||
=={{header|Intercal}}== |
|||
<syntaxhighlight lang="intercal">PLEASE NOTE This is a comment</syntaxhighlight> |
|||
=={{header|Io}}== |
=={{header|Io}}== |
||
< |
<syntaxhighlight lang="io"># Single-line comment |
||
// Single-line comment |
// Single-line comment |
||
/* Multi-line |
/* Multi-line |
||
comment */</ |
comment */</syntaxhighlight> |
||
=={{header|Isabelle}}== |
|||
<syntaxhighlight lang="isabelle">theory Text |
|||
imports Main |
|||
begin |
|||
(* Top-level Isar comment. *) |
|||
end</syntaxhighlight> |
|||
=={{header|J}}== |
=={{header|J}}== |
||
< |
<syntaxhighlight lang="j">NB. Text that follows 'NB.' has no effect on execution. |
||
'Character strings in J may have their value be ignored and treated as comment text.' |
|||
0 : 0 |
0 : 0 |
||
Line 690: | Line 1,496: | ||
Another way to record multi-line comments as text is to use 'Note', which is actually |
Another way to record multi-line comments as text is to use 'Note', which is actually |
||
a simple program that makes it clearer when defined text is used only to provide comment. |
a simple program that makes it clearer when defined text is used only to provide comment. |
||
) |
|||
)</lang> |
|||
{{)n |
|||
J release 9's nestable blocks can be used as comments. |
|||
Typically, this would be in contexts where the blocks would not be used. |
|||
That said, "literate coding practices" may stretch the boundaries here. |
|||
Also, noun blocks (beginning with ')n') avoid syntactic concerns about content. |
|||
These blocks even allow contained '}}' sequences to be ignored (unless, of |
|||
course the }} character pair appears at the beginning of a line). |
|||
}}</syntaxhighlight> |
|||
=={{header|Java}}== |
=={{header|Java}}== |
||
Java has two ways to enter normal comments, plus a third type of comment that doubles as a way to generate HTML documentation. |
Java has two ways to enter normal comments, plus a third type of comment that doubles as a way to generate HTML documentation. |
||
===C Style=== |
===C Style=== |
||
< |
<syntaxhighlight lang="java">/* This is a comment */</syntaxhighlight> |
||
< |
<syntaxhighlight lang="java">/* |
||
* This is |
* This is |
||
* a multiple |
* a multiple |
||
* line comment. |
* line comment. |
||
*/</ |
*/</syntaxhighlight> |
||
This ''C-style'' comment starts with <tt>/*</tt> and ends with <tt>*/</tt>. |
This ''C-style'' comment starts with <tt>/*</tt> and ends with <tt>*/</tt>. |
||
The two delimiters may be on the same or separate lines. |
The two delimiters may be on the same or separate lines. |
||
This style comment may be used anywhere white space is permitted. |
This style comment may be used anywhere white space is permitted. |
||
===C++ Style (inline)=== |
===C++ Style (inline)=== |
||
<lang |
<syntaxhighlight lang="java">// This is a comment</syntaxhighlight> |
||
This ''C++-style'' comment starts with <tt>//</tt> and extends to the end of line. |
This ''C++-style'' comment starts with <tt>//</tt> and extends to the end of line. |
||
===Java Documentation (Javadoc)=== |
===Java Documentation (Javadoc)=== |
||
< |
<syntaxhighlight lang="java">/** This is a Javadoc comment */</syntaxhighlight> |
||
< |
<syntaxhighlight lang="java">/** |
||
* This is |
* This is |
||
* a multiple |
* a multiple |
||
* line Javadoc comment |
* line Javadoc comment |
||
*/</ |
*/</syntaxhighlight> |
||
[http://en.wikipedia.org/wiki/Javadoc Javadoc] is a standardized documentation code for Java. Its comments begin with a forward slash and two stars. Javadoc comments have different tags that signify different things in the methods and classes that they precede. |
[http://en.wikipedia.org/wiki/Javadoc Javadoc] is a standardized documentation code for Java. Its comments begin with a forward slash and two stars. Javadoc comments have different tags that signify different things in the methods and classes that they precede. |
||
===Sneaky=== |
|||
Your editor will probably colour this as great big comment, but it compiles and prints "Hello World!". Once you've figured out how this works, try this [http://stackoverflow.com/questions/4448180/why-does-java-permit-escaped-unicode-characters-in-the-source-code discussion on why it's allowed]. |
|||
<syntaxhighlight lang="java">public class JustComments { |
|||
/* |
|||
\u002A\u002F\u0070\u0075\u0062\u006C\u0069\u0063\u0020\u0073\u0074\u0061\u0074\u0069\u0063 |
|||
\u0020\u0076\u006F\u0069\u0064\u0020\u006D\u0061\u0069\u006E\u0028 |
|||
\u0053\u0074\u0072\u0069\u006E\u0067\u005B\u005D\u0061\u0072\u0067\u0073\u0029 |
|||
\u007B\u0053\u0079\u0073\u0074\u0065\u006D\u002E\u006F\u0075\u0074\u002E |
|||
\u0070\u0072\u0069\u006E\u0074\u006C\u006E\u0028\u0022\u0048\u0065\u006C\u006C\u006F\u0022 |
|||
\u002B\u0022\u0020\u0057\u006F\u0072\u006C\u0064\u0021\u0022\u0029\u003B\u007D\u002F\u002A |
|||
*/ |
|||
}</syntaxhighlight> |
|||
=={{header|JavaScript}}== |
=={{header|JavaScript}}== |
||
<syntaxhighlight lang="javascript">n = n + 1; // This is a comment</syntaxhighlight> |
|||
:''See [[Comments#Java|Java]]'' |
|||
<syntaxhighlight lang="javascript">// This is a valid comment // with a "nested" comment</syntaxhighlight> |
|||
<syntaxhighlight lang="javascript">/* This is |
|||
a multi line |
|||
comment |
|||
// with a "nested" comment |
|||
and another line in the comment |
|||
*/</syntaxhighlight> |
|||
=={{header|JCL}}== |
|||
first form |
|||
<syntaxhighlight lang="jcl"> |
|||
//* This is a comment line (//* in columns 1-3) |
|||
</syntaxhighlight> |
|||
second form |
|||
<syntaxhighlight lang="jcl"> |
|||
/* This is also a comment line (/* in columns 1-3) |
|||
</syntaxhighlight> |
|||
=={{header|Joy}}== |
=={{header|Joy}}== |
||
< |
<syntaxhighlight lang="joy"># this is a single line comment |
||
(* this is a |
(* this is a |
||
multi-line comment *)</ |
multi-line comment *)</syntaxhighlight> |
||
Multi-line comments cannot be nested. |
Multi-line comments cannot be nested. |
||
=={{header|jq}}== |
|||
Except when a hash symbol (#) appears within a string, it begins a comment that continues to the end of the line: |
|||
<syntaxhighlight lang="jq"># this is a single line comment |
|||
"Hello #world" # the first # on this line is part of the jq program |
|||
</syntaxhighlight> |
|||
=={{header|Jsish}}== |
|||
<syntaxhighlight lang="javascript">#!/usr/bin/env/jsish |
|||
/* Comments, in Jsish */ |
|||
// to end of line comment, double slash |
|||
/* |
|||
Enclosed comment, slash star, ending with star slash |
|||
Cannot be nested, but can cross line boundaries and occur |
|||
pretty much anywhere whitespace is allowed |
|||
*/ |
|||
var x = 'X'; /* A var called X */ |
|||
/* active code on this line */ printf("Result %q %d\n", /* comment code mix */ x, /**/42); |
|||
;x; |
|||
// jsish also handles double slash commented |
|||
// unit test echo lines as a special case of "expect failure" |
|||
;//noname(x); |
|||
/* |
|||
=!EXPECTSTART!= |
|||
Result X 42 |
|||
x ==> X |
|||
noname(x) ==> |
|||
PASS!: err = can not execute expression: 'noname' not a function |
|||
=!EXPECTEND!= |
|||
*/</syntaxhighlight> |
|||
{{out}} |
|||
<pre>prompt$ jsish comments.jsi |
|||
Result X 42 |
|||
prompt$ jsish --U comments.jsi |
|||
Result X 42 |
|||
x ==> X |
|||
noname(x) ==> |
|||
PASS!: err = can not execute expression: 'noname' not a function |
|||
prompt$ jsish -u comments.jsi |
|||
[PASS] comments.jsi</pre> |
|||
=={{header|Julia}}== |
|||
<syntaxhighlight lang="julia"># single line |
|||
#= |
|||
Multi- |
|||
line |
|||
comment |
|||
=#</syntaxhighlight> |
|||
=={{header|K}}== |
|||
<syntaxhighlight lang="k"> / this is a comment |
|||
2+2 / as is this |
|||
</syntaxhighlight> |
|||
=={{header|KonsolScript}}== |
=={{header|KonsolScript}}== |
||
< |
<syntaxhighlight lang="konsolscript">//This is a comment. |
||
//This is another comment. |
//This is another comment. |
||
Line 739: | Line 1,648: | ||
/* This is a |
/* This is a |
||
multi-line |
multi-line |
||
comment */</ |
comment */</syntaxhighlight> |
||
=={{header|Kotlin}}== |
|||
<syntaxhighlight lang="scala">// This is a single line comment |
|||
/* |
|||
This is a |
|||
multi-line |
|||
comment |
|||
*/ |
|||
/* |
|||
Multi-line comments |
|||
/* |
|||
can also be nested |
|||
*/ |
|||
like so |
|||
*/ |
|||
const val CURRENT_VERSION = "1.0.5-2" // A comment can also be added at the end of a line |
|||
const val /* or even in the middle of a line */ NEXT_MAJOR_VERSION = "1.1" |
|||
/** |
|||
* This is a documentation comment used by KDoc. |
|||
* |
|||
* It's documenting the main function which is the entry-point to a Kotlin executable. |
|||
* |
|||
* @param [args] A string array containing the command line arguments (if any) passed to the executable |
|||
* @return Implicit return value is Unit which signifies no meaningful return value (like 'void' in java) |
|||
*/ |
|||
fun main(args: Array<String>) { |
|||
println("Current stable version is $CURRENT_VERSION") |
|||
println("Next major version is $NEXT_MAJOR_VERSION") |
|||
}</syntaxhighlight> |
|||
=={{header|Lambdatalk}}== |
|||
<syntaxhighlight lang="scheme"> |
|||
Out of bracketed expressions words are ignored by the lambdatalk evaluator and are dislayed as they are: |
|||
Hello World |
|||
-> Hello World |
|||
In order to prevent any evaluation and display of some parts of code put them inside triple degrees "°°°": |
|||
°°° |
|||
this is |
|||
a comment ... and an expression {+ 1 2} |
|||
on several lines |
|||
°°° |
|||
</syntaxhighlight> |
|||
=={{header|LabVIEW}}== |
|||
{{VI solution|LabVIEW_Comments.png}} |
|||
=={{header|Lang}}== |
|||
Single line |
|||
<syntaxhighlight lang="lang5"> |
|||
# This is a comment |
|||
</syntaxhighlight> |
|||
Multiline (Line continuation) |
|||
<syntaxhighlight lang="lang5"> |
|||
# This is a comment\ |
|||
with multiple lines |
|||
</syntaxhighlight> |
|||
Multiline (Multiline text sequence) |
|||
<syntaxhighlight lang="lang5"> |
|||
# {{{This is a comment |
|||
which has more than |
|||
2 lines |
|||
and this one}}} |
|||
</syntaxhighlight> |
|||
=={{header|Lang5}}== |
|||
<syntaxhighlight lang="lang5"># This is a comment.</syntaxhighlight> |
|||
=={{header|langur}}== |
|||
Langur has 2 types of comments. |
|||
<syntaxhighlight lang="langur"># single line comment starts with hash mark |
|||
/* inline or multi-line comment uses C-style syntax */ |
|||
</syntaxhighlight> |
|||
=={{header|Lasso}}== |
|||
<syntaxhighlight lang="lasso ">//This is a comment. |
|||
/* This is also a comment. */ |
|||
/* A multi-line |
|||
comment */ |
|||
/* ========================== |
|||
A multi-line |
|||
comment |
|||
=========================== */</syntaxhighlight> |
|||
=={{header|LaTeX}}== |
=={{header|LaTeX}}== |
||
In LaTeX, comments look like this: |
In LaTeX, comments look like this: |
||
<syntaxhighlight lang="latex">\documentclass{minimal} |
|||
<lang latex>% This is a comment</lang> |
|||
\begin{document} |
|||
% This is a comment |
|||
\end{document}</syntaxhighlight> |
|||
LaTeX comments start with <tt>%</tt> and continue up to ''and including'' the line break. The fact that the line break itself is commented out as well makes it useful for adding line breaks in the source code of complex macros without LaTeX interpreting them (which may cause extra space or even a paragraph break in the resulting typeset text). For example, the following results in the ''one'' word "understandable": |
LaTeX comments start with <tt>%</tt> and continue up to ''and including'' the line break. The fact that the line break itself is commented out as well makes it useful for adding line breaks in the source code of complex macros without LaTeX interpreting them (which may cause extra space or even a paragraph break in the resulting typeset text). For example, the following results in the ''one'' word "understandable": |
||
<lang |
<syntaxhighlight lang="latex">\documentclass{minimal} |
||
\newcommand{\firstpart}[1]{under#1} |
|||
\newcommand{\secondpart}{able} |
\newcommand{\secondpart}{able} |
||
\newcommand{\complete}{% |
\newcommand{\complete}{% |
||
\firstpart% |
\firstpart{stand}% |
||
\secondpart} |
\secondpart} |
||
\begin{document} |
|||
\complete |
\complete |
||
\end{document}</syntaxhighlight> |
|||
Without the percent sign after <tt>\firstpart</tt>, it would have been the ''two'' words "understand able". |
|||
Without the percent sign after <tt>\firstpart{stand}</tt>, it would have been the ''two'' words "understand able". |
|||
=={{header|Liberty BASIC}}== |
=={{header|Liberty BASIC}}== |
||
< |
<syntaxhighlight lang="lb">'This is a comment |
||
REM This is a comment |
REM This is a comment |
||
print "This has a comment on the end of the line." 'This is a comment |
print "This has a comment on the end of the line." 'This is a comment |
||
print "This also has a comment on the end of the line." : REM This is a comment</ |
print "This also has a comment on the end of the line." : REM This is a comment</syntaxhighlight> |
||
=={{header|Lily}}== |
|||
There are two kinds of comments: |
|||
<syntaxhighlight lang="lily"># This is a single-line comment</syntaxhighlight> |
|||
and |
|||
<syntaxhighlight lang="lily">#[ This |
|||
is |
|||
a |
|||
block |
|||
comment ]#</syntaxhighlight> |
|||
Like with C, block comments don't nest. |
|||
=={{header|LilyPond}}== |
|||
<syntaxhighlight lang="lilypond">% This is a comment |
|||
%{ This is a comment |
|||
spanning several lines %}</syntaxhighlight> |
|||
=={{header|Lingo}}== |
|||
In Lingo any line starting with "--" is a comment and ignored by the interpreter. |
|||
<syntaxhighlight lang="lingo">-- This is a comment. |
|||
-- This is another comment</syntaxhighlight> |
|||
=={{header|LiveCode}}== |
|||
<syntaxhighlight lang="livecode">-- comment may appear anywhere on line |
|||
// comment may appear anywhere on line |
|||
# comment may appear anywhere on line |
|||
/* this is a |
|||
block comment that |
|||
may span any number of lines */</syntaxhighlight> |
|||
=={{header|Logo}}== |
=={{header|Logo}}== |
||
< |
<syntaxhighlight lang="logo">; comments come after a semicolon, and last until the end of the line</syntaxhighlight> |
||
=={{header|Logtalk}}== |
=={{header|Logtalk}}== |
||
< |
<syntaxhighlight lang="logtalk">% single-line comment; extends to the end of the line</syntaxhighlight> |
||
< |
<syntaxhighlight lang="logtalk">/* multi-line |
||
comment */</ |
comment */</syntaxhighlight> |
||
=={{header|LOLCODE}}== |
|||
<syntaxhighlight lang="lolcode">OBTW This is a |
|||
multi line comment |
|||
TLDR</syntaxhighlight> |
|||
<syntaxhighlight lang="lolcode">BTW This is a single line comment.</syntaxhighlight> |
|||
=={{header|LotusScript}}== |
=={{header|LotusScript}}== |
||
LotusScript has two ways to enter comments. |
LotusScript has two ways to enter comments. |
||
<lang |
<syntaxhighlight lang="lotusscript">' This is a comment</syntaxhighlight> |
||
Wherever the single quote (<tt>'</tt>) is used, the rest of the line is treated as a comment and ignored. Multi-line comments would each need a single quote mark. This style of comment is usually used for making small in-line or single line comments. |
Wherever the single quote (<tt>'</tt>) is used, the rest of the line is treated as a comment and ignored. Multi-line comments would each need a single quote mark. This style of comment is usually used for making small in-line or single line comments. |
||
< |
<syntaxhighlight lang="lotusscript">%REM |
||
This is a multi- |
This is a multi- |
||
line comment. |
line comment. |
||
%END REM</ |
%END REM</syntaxhighlight> |
||
A <tt>%REM</tt> marker begins a comment block, and a <tt>%END REM</tt> marker ends the comment block. This style of comment is used for making longer multi-line comments, often at the beginning of a class, sub or function. |
A <tt>%REM</tt> marker begins a comment block, and a <tt>%END REM</tt> marker ends the comment block. This style of comment is used for making longer multi-line comments, often at the beginning of a class, sub or function. |
||
=={{header|LSE}}== |
|||
<syntaxhighlight lang="lse">* Ceci est un commentaire qui prend fin quand la ligne se termine |
|||
(* Ceci est un commentaire sur plusieurs lignes |
|||
comme vous pouvez le voir puisqu'il s'étend sur |
|||
plusieurs lignes justement... *) |
|||
(* Cette exemple est selon la revision LSE-2000 *)</syntaxhighlight> |
|||
=={{header|LSE64}}== |
=={{header|LSE64}}== |
||
< |
<syntaxhighlight lang="lse64"># single line comment (space after # is required)</syntaxhighlight> |
||
The author of |
The author of LSE64 comments the stack effect of words with header comments as follows: |
||
< |
<syntaxhighlight lang="lse64"># arg1 arg2 '''yields''' result|''nothing''</syntaxhighlight> |
||
=={{header|Lua}}== |
=={{header|Lua}}== |
||
< |
<syntaxhighlight lang="lua">-- A single line comment |
||
--[[A multi-line |
--[[A multi-line |
||
comment --]]</ |
comment --]]</syntaxhighlight> |
||
{{works with|Lua|5.1 and above}} |
{{works with|Lua|5.1 and above}} |
||
< |
<syntaxhighlight lang="lua">--[====[ A multi-line comment that can contain [[ many square brackets ]] |
||
]====]</ |
]====]</syntaxhighlight> |
||
=={{header|M2000 Interpreter}}== |
|||
Multiline commend Ret { lines of code, or text } |
|||
Same line comment until end of line (can start immediate after a command: use ' or \ or // |
|||
Rem (form start of code line) |
|||
(:\ and \\ or \) in a name can exist only for Dir statement: |
|||
dir c:\thatfolder |
|||
is the same as |
|||
dir "c:\thatfolder" |
|||
<syntaxhighlight lang="m2000 interpreter"> |
|||
Module Comments { |
|||
Rem { |
|||
Print "no print here" |
|||
? "no print here either" |
|||
} |
|||
Rem : single line remark |
|||
// single line |
|||
\ single line |
|||
' single line |
|||
? "ok" : Rem : Print "not print - but code have syntax highlight" |
|||
? "ok" // single line - start without double colon |
|||
? "ok" \ single line - start without double colon |
|||
Print "ok" ' single line |
|||
} |
|||
Comments |
|||
</syntaxhighlight> |
|||
=={{header|M4}}== |
=={{header|M4}}== |
||
<lang M4>eval(2*3) # eval(2*3) "#" and text after it aren't processed but passed along |
|||
<syntaxhighlight lang="m4">eval(2*3) # eval(2*3) "#" and text after it aren't processed but passed along |
|||
dnl this text completely disappears, including the new line |
dnl this text completely disappears, including the new line |
||
divert(-1) |
divert(-1) |
||
Everything diverted to -1 is processed but the output is discarded. |
Everything diverted to -1 is processed but the output is discarded. |
||
A comment could take this form as long as no macro names are used. |
A comment could take this form as long as no macro names are used. |
||
divert</ |
divert</syntaxhighlight> |
||
{{out}} |
|||
Output: |
|||
<pre>6 # eval(2*3) "#" and text after it aren't processed but passed along</pre> |
|||
<code>dnl</code> must be a separate word. |
|||
An empty pair of quotes |
|||
can separate it from preceding text if necessary |
|||
<syntaxhighlight lang="m4">some text`'dnl then a deleted comment</syntaxhighlight> |
|||
<code>changecom()</code> can set a different character for <code>#</code>, |
|||
<syntaxhighlight lang="m4">changecom(%) |
|||
% now percent prevents macro expansion</syntaxhighlight> |
|||
In GNU m4 an empty <code>changecom()</code> string means no such commenting char at all (but in BSD m4 means reset to the default <code>#</code>) |
|||
<syntaxhighlight lang="m4">changecom() |
|||
GNU m4 now no macro expansion suppression character at all</syntaxhighlight> |
|||
In GNU m4 <code>changecom()</code> also takes separate start and end strings and they can be multi-character sequences, allowing for example C style, |
|||
<syntaxhighlight lang="m4">changecom(/*,*/) |
|||
/* GNU m4 now no macro expansion in C style comments */</syntaxhighlight> |
|||
=={{header|Maple}}== |
|||
<syntaxhighlight lang="maple">x := 4: x; # Everything on this line, after this, is a comment. |
|||
17; (* This |
|||
is |
|||
a multiline comment *) 23.4;</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
<pre> |
||
4 |
|||
6 # eval(2*3) "#" and text after it aren't processed but passed along |
|||
17 |
|||
23.4 |
|||
</pre> |
</pre> |
||
=={{header|Mathematica}}== |
=={{header|Mathematica}} / {{header|Wolfram Language}}== |
||
<lang |
<syntaxhighlight lang="mathematica">(*this is a comment*)</syntaxhighlight> |
||
It can be used everywhere and nested if necessary: |
It can be used everywhere and nested if necessary: |
||
< |
<syntaxhighlight lang="mathematica">If[a(*number 1*)<(* is smaller than number 2*) b, True (*return value (*bool true*)*), False (*return bool false*)]</syntaxhighlight> |
||
evaluates to: |
evaluates to: |
||
< |
<syntaxhighlight lang="mathematica">If[a < b, True, False]</syntaxhighlight> |
||
=={{header|MATLAB}}== |
=={{header|MATLAB}}== |
||
< |
<syntaxhighlight lang="matlab">%This is a comment |
||
%% Two percent signs and a space are called a cell divider</ |
%% Two percent signs and a space are called a cell divider</syntaxhighlight> |
||
=={{header|Maxima}}== |
|||
<syntaxhighlight lang="maxima">/* Comment |
|||
/* Nested comment */ |
|||
*/</syntaxhighlight> |
|||
=={{header|MAXScript}}== |
=={{header|MAXScript}}== |
||
< |
<syntaxhighlight lang="maxscript">-- Two dashes precede a single line comment |
||
/* This is a |
/* This is a |
||
multi-line comment */</ |
multi-line comment */</syntaxhighlight> |
||
=={{header|MBS}}== |
=={{header|MBS}}== |
||
< |
<syntaxhighlight lang="mbs">! A pling in a line starts a comment |
||
INT n:=5 ! Comments can appear at the end of a line |
INT n:=5 ! Comments can appear at the end of a line |
||
/* A comment block can also be defined using climbstar and starclimb symbols. |
/* A comment block can also be defined using climbstar and starclimb symbols. |
||
This allows comments to be stretched across several lines */</ |
This allows comments to be stretched across several lines */</syntaxhighlight> |
||
=={{header|MEL}}== |
|||
<syntaxhighlight lang="mel">// This is a single line comment</syntaxhighlight> |
|||
=={{header|Metafont}}== |
=={{header|Metafont}}== |
||
< |
<syntaxhighlight lang="metafont">% this is "to-end-of-line" comment</syntaxhighlight> |
||
=={{header|Microsoft Small Basic}}== |
|||
Microsoft Small Basic uses the quote symbol to mark it's comments. After placing a quote everything in that line will be ignored. |
|||
<syntaxhighlight lang="smallbasic">' This is a comment |
|||
i = i + 1 ' You can also append comments to statements</syntaxhighlight> |
|||
=={{header|min}}== |
|||
{{works with|min|0.19.3}} |
|||
<syntaxhighlight lang="min">; this is a comment |
|||
1 1 + ; add one and one together</syntaxhighlight> |
|||
=={{header|MiniScript}}== |
|||
MiniScript just has one kind of comment. They begin with two slashes, and extend to the |
|||
end of a line. So you can put a comment either on a line by itself, or after a statement. |
|||
<syntaxhighlight lang="miniscript">// How many roads must a man walk down? |
|||
x = 6 * 7 // forty-two</syntaxhighlight> |
|||
=={{header|Mirah}}== |
=={{header|Mirah}}== |
||
< |
<syntaxhighlight lang="mirah">puts 'code' # I am a comment |
||
/* This is |
/* This is |
||
* a multiple |
* a multiple |
||
* line comment */ |
* line comment */ |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|MIPS Assembly}}== |
|||
This is ultimately up to the assembler, but semicolons are typically the comment character for almost all assemblers. |
|||
<syntaxhighlight lang="mips">;this is a comment |
|||
li $t0,0x1234 ;this is also a comment</syntaxhighlight> |
|||
However, MARS and QTSPIM use the <code>#</code>. |
|||
<syntaxhighlight lang="mips"># this is a comment |
|||
li $t0,0x1234 # this is also a comment</syntaxhighlight> |
|||
=={{header|mIRC Scripting Language}}== |
|||
<syntaxhighlight lang="mirc">;Single Line Comment |
|||
/* |
|||
Multiple |
|||
Line |
|||
Comment |
|||
*/</syntaxhighlight> |
|||
=={{header|Modula-2}}== |
=={{header|Modula-2}}== |
||
< |
<syntaxhighlight lang="modula-2">(* Comments (* can nest *) |
||
and they can span multiple lines. |
and they can span multiple lines. |
||
*)</ |
*)</syntaxhighlight> |
||
=={{header|Modula-3}}== |
=={{header|Modula-3}}== |
||
< |
<syntaxhighlight lang="modula3">(* Comments (* can nest *) |
||
and they can span multiple lines. |
and they can span multiple lines. |
||
*)</ |
*)</syntaxhighlight> |
||
=={{header|Monte}}== |
|||
<syntaxhighlight lang="monte"> |
|||
# This comment goes to the end of the line |
|||
/** This comment is multi-line. |
|||
Yes, it starts with a two stars |
|||
and ends with only one. |
|||
These should only be used for docstrings. */ |
|||
</syntaxhighlight> |
|||
=={{header|MontiLang}}== |
|||
<syntaxhighlight lang="montilang"> |
|||
/# This is a comment #/ |
|||
/# |
|||
comments can span multiple lines |
|||
nested comments are not supported #/ |
|||
</syntaxhighlight> |
|||
=={{header|MOO}}== |
=={{header|MOO}}== |
||
< |
<syntaxhighlight lang="moo">"String literals are technically the only long-term comment format"; |
||
// Some compilers will, however, compile // one-liners to string literals as well (and vice-versa) |
// Some compilers will, however, compile // one-liners to string literals as well (and vice-versa) |
||
/* Classical C-style comments are removed entirely during compile */</ |
/* Classical C-style comments are removed entirely during compile */</syntaxhighlight> |
||
=={{header|Nanoquery}}== |
|||
Comments in Nanoquery must be on a single line. |
|||
<syntaxhighlight lang="nanoquery">// this is a comment |
|||
// this is also a comment</syntaxhighlight> |
|||
=={{header|NATURAL}}== |
|||
<syntaxhighlight lang="natural">* This is a comment and extends to the end of the line </syntaxhighlight> |
|||
=={{header|Neko}}== |
|||
<syntaxhighlight lang="actionscript">// Single line comment, of course! |
|||
/* |
|||
Multi line comment! |
|||
*/ |
|||
/** |
|||
Documentation block |
|||
<doc>can include XML parsed nodes between doc tags</doc> |
|||
**/</syntaxhighlight> |
|||
=={{header|Nemerle}}== |
=={{header|Nemerle}}== |
||
< |
<syntaxhighlight lang="nemerle">// This comment goes up to the end of the line |
||
/* This |
/* This |
||
is |
is |
||
a |
a |
||
multiline |
multiline |
||
comment */</ |
comment */</syntaxhighlight> |
||
=={{header|NESL}}== |
|||
<syntaxhighlight lang="nesl">% This is a comment. %</syntaxhighlight> |
|||
=={{header|NetRexx}}== |
|||
NetRexx supports block-comments and line comments. Block comments are started with a <code>'''/*'''</code> and terminated with a <code>'''*/'''</code>. Line comments follow a <code>'''--'''</code> sequence anywhere on a line. |
|||
NetRexx supports nested comments (see [[#REXX|REXX]]). |
|||
<syntaxhighlight lang="netrexx">/* |
|||
NetRexx comment block |
|||
*/ |
|||
-- NetRexx line comment |
|||
</syntaxhighlight> |
|||
=={{header|NewLISP}}== |
=={{header|NewLISP}}== |
||
A comment is started by <code>;</code> and reaches to the end of the line. |
A comment is started by <code>;</code> and reaches to the end of the line. |
||
<lang |
<syntaxhighlight lang="lisp">; This is a comment</syntaxhighlight> |
||
=={{header|Nim}}== |
|||
<syntaxhighlight lang="python"># Nim supports single-line comments |
|||
var x = 0 ## Documentation comments start with double hash characters. |
|||
var y = 0 ## Documentation comments are a proper part of the syntax (they're not discarded by parser, and a real part of AST). |
|||
#[ |
|||
There are also multi-line comments |
|||
Everything inside of #[]# is commented. |
|||
]# |
|||
# You can also discard multiline statements: |
|||
discard """This can be considered as a "comment" too |
|||
This is multi-line""" |
|||
</syntaxhighlight> |
|||
=={{header|Nix}}== |
|||
<syntaxhighlight lang="nix"># This comment goes up to the end of the line |
|||
/* This |
|||
is |
|||
a |
|||
multiline |
|||
comment */</syntaxhighlight> |
|||
=={{header|NSIS}}== |
=={{header|NSIS}}== |
||
< |
<syntaxhighlight lang="nsis"> |
||
# This is a comment that goes from the # to the end of the line. |
# This is a comment that goes from the # to the end of the line. |
||
; This is a comment that goes from the ; to the end of the |
; This is a comment that goes from the ; to the end of the |
||
Line 880: | Line 2,135: | ||
multi-line |
multi-line |
||
comment */ |
comment */ |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header| |
=={{header|Oberon-2}}== |
||
<syntaxhighlight lang="oberon2"> |
|||
:''See [[Comments#C|C]]'' |
|||
(* this is a comment *) |
|||
(* |
|||
and this is a |
|||
multiline comment |
|||
(* with a nested comment *) |
|||
*) |
|||
</syntaxhighlight> |
|||
=={{header|Objeck}}== |
=={{header|Objeck}}== |
||
< |
<syntaxhighlight lang="objeck"> |
||
#This is a comment. |
#This is a comment. |
||
# This is other comment. |
# This is other comment. |
||
Line 895: | Line 2,157: | ||
multi-line |
multi-line |
||
comment ~# |
comment ~# |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Objective-C}}== |
|||
:''See [[Comments#C|C]]'' |
|||
=={{header|OCaml}}== |
=={{header|OCaml}}== |
||
< |
<syntaxhighlight lang="ocaml">(* This a comment |
||
(* containing nested comment *) |
(* containing nested comment *) |
||
*) |
*) |
||
(** This an OCamldoc documentation comment *)</ |
(** This an OCamldoc documentation comment *)</syntaxhighlight> |
||
=={{header|Octave}}== |
=={{header|Octave}}== |
||
< |
<syntaxhighlight lang="octave"># I am a comment till the end of line |
||
% I am a comment till the end of line |
% I am a comment till the end of line |
||
%{ |
|||
This comment spans |
|||
multiple lines |
|||
%} |
|||
</syntaxhighlight> |
|||
=={{header|Oforth}}== |
|||
Oforth has only single line comment (inside or outside definition) |
|||
<syntaxhighlight lang="oforth">// This is a comment...</syntaxhighlight> |
|||
=={{header|ooRexx}}== |
|||
Comments in ooRexx follow the same rules as [[#REXX|REXX]] and [[#NetRexx|NetRexx]] |
|||
<syntaxhighlight lang="oorexx">/* |
|||
Multi-line comment block |
|||
*/ |
|||
-- this type of comment works in ooRexx, NetRexx and some of the more popular REXX implementations like Regina |
|||
hour = 0 -- which is, like midnight, dude. |
|||
hour = 12 /* time for lunch! works as well (and really everywhere) */ |
|||
</syntaxhighlight> |
|||
=={{header|Openscad}}== |
=={{header|Openscad}}== |
||
The openscad geometry compiler supports C++ style comments: |
The openscad geometry compiler supports C++ style comments: |
||
< |
<syntaxhighlight lang="openscad"> |
||
// This is a single line comment |
// This is a single line comment |
||
Line 920: | Line 2,211: | ||
*/ |
*/ |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|OxygenBasic}}== |
|||
<syntaxhighlight lang="oxygenbasic"> |
|||
' Basic line comment |
|||
; Assembly code line comment |
|||
// C line comment |
|||
/* C block comment */ |
|||
</syntaxhighlight> |
|||
=={{header|Oz}}== |
=={{header|Oz}}== |
||
< |
<syntaxhighlight lang="oz">% one line comment |
||
%% often with double "%" because then the indentation is correct in Emacs |
%% often with double "%" because then the indentation is correct in Emacs |
||
Line 930: | Line 2,229: | ||
comment |
comment |
||
*/ |
*/ |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|PARI/GP}}== |
=={{header|PARI/GP}}== |
||
Line 936: | Line 2,235: | ||
=={{header|Pascal}}== |
=={{header|Pascal}}== |
||
< |
<syntaxhighlight lang="pascal">(* This is a comment. |
||
It may extend across multiple lines. *) |
It may extend across multiple lines. *) |
||
Line 945: | Line 2,244: | ||
but not valid in [[Turbo Pascal]]. } |
but not valid in [[Turbo Pascal]]. } |
||
{ The same is true in this case *)</ |
{ The same is true in this case *)</syntaxhighlight> |
||
In Pascal, comments cannot be nested. |
In Pascal, comments cannot be nested. |
||
=={{header|PascalABC.NET}}== |
|||
<syntaxhighlight lang="pascal"> |
|||
(* This is a |
|||
multiline comment *) |
|||
{ This is also a |
|||
multiline comment } |
|||
// This is a single line comment |
|||
</syntaxhighlight> |
|||
=={{header|PASM}}== |
=={{header|PASM}}== |
||
< |
<syntaxhighlight lang="pasm"># This is a comment |
||
print "Hello\n" # This is also a comment |
print "Hello\n" # This is also a comment |
||
end</ |
end</syntaxhighlight> |
||
=={{header|Peloton}}== |
|||
Peloton encloses all comments inside <@ OMT></@> (fixed length opcode) or <# OMIT></#> (variable length opcode) whether single- or multi- line. |
|||
<syntaxhighlight lang="html"> |
|||
<@ OMT>This is a |
|||
multiline |
|||
comment</@> |
|||
</syntaxhighlight> |
|||
OMT suppresses evaluation of everything contained. There are a variety of extra opcodes which can be used to control how OMT functions at run time. |
|||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
Line 959: | Line 2,279: | ||
Single line comment |
Single line comment |
||
<lang |
<syntaxhighlight lang="perl"># this is commented</syntaxhighlight> |
||
These may also be at the end of a line |
These may also be at the end of a line |
||
< |
<syntaxhighlight lang="perl">my $var = 1; # this is the comment part</syntaxhighlight> |
||
Multi-line comments for inline documentation (Plain Old Documentation, or POD in Perl parlance) follow the format: |
Multi-line comments for inline documentation (Plain Old Documentation, or POD in Perl parlance) follow the format: |
||
< |
<syntaxhighlight lang="perl">=pod |
||
Here are my comments |
Here are my comments |
||
this is multi-line |
this is multi-line |
||
=cut</ |
=cut</syntaxhighlight> |
||
Note that technically, both of the lines beginning with the equals sign must be surrounded on either side for compatibility with all "POD" parsers. |
Note that technically, both of the lines beginning with the equals sign must be surrounded on either side for compatibility with all "POD" parsers. |
||
Line 978: | Line 2,298: | ||
Note also that any string beginning with an equals sign, and that appears in the initial column of a line, begins a multi-line comment. It does not have to be a POD "command:" the following are all valid: |
Note also that any string beginning with an equals sign, and that appears in the initial column of a line, begins a multi-line comment. It does not have to be a POD "command:" the following are all valid: |
||
< |
<syntaxhighlight lang="perl">=head1 |
||
=head4 |
=head4 |
||
=over 4 |
=over 4 |
||
=Any Old String</ |
=Any Old String</syntaxhighlight> |
||
Such blocks always end in =cut. |
Such blocks always end in =cut. |
||
Line 987: | Line 2,307: | ||
For more info, type at a command prompt (or into a search engine): "perldoc perlpod" |
For more info, type at a command prompt (or into a search engine): "perldoc perlpod" |
||
=={{header| |
=={{header|Phix}}== |
||
{{libheader|Phix/basics}} |
|||
{{works with|Rakudo|#22 "Thousand Oaks"}} |
|||
Single line comment: |
|||
<!--<syntaxhighlight lang="phix">(phixonline)--> |
|||
<span style="color: #000080;font-style:italic;">-- this is a comment. |
|||
// this is also a comment. </span> |
|||
<!--</syntaxhighlight>--> |
|||
Nestable multiline comments: |
|||
<lang perl6>my $x = 2; # Single-line comment. |
|||
<!--<syntaxhighlight lang="phix">--> |
|||
<span style="color: #000080;font-style:italic;">/* |
|||
#`( |
|||
This is a comment |
|||
Comments beginning with a backtick and one or more |
|||
procedure oldproc() |
|||
opening bracketing characters are embedded comments. |
|||
/* |
|||
They can span more than one line… |
|||
This is also a comment |
|||
) |
|||
*/ |
|||
puts(1,"kill me now") |
|||
my $y = #`{ …or only part of a line. } 3; |
|||
end procedure |
|||
*/</span> |
|||
#`{{ |
|||
<span style="color: #7060A8;">puts<span style="color: #0000FF;">(<span style="color: #000000;">1<span style="color: #0000FF;">,<span style="color: #008000;">"this is not a comment"<span style="color: #0000FF;">) |
|||
Using more than one bracketing character lets you include |
|||
<!--</syntaxhighlight>--> |
|||
an unmatched close bracket, like this: } |
|||
}} |
{{out}} |
||
<pre> |
|||
this is not a comment |
|||
#`⁅ Synopsis 2: "Bracketing characters are defined as any |
|||
</pre> |
|||
Unicode characters with either bidirectional mirrorings or |
|||
In fact there are now a total of six(!) different types of comment in Phix: |
|||
Ps/Pe/Pi/Pf properties." ⁆ |
|||
#! opening shebang |
|||
#[ .. #] for multiline shebangs |
|||
=begin comment |
|||
-- standard line comments |
|||
// C-style line comments |
|||
Pod is the successor to Perl 5's POD. This is the simplest way |
|||
/* .. */ standard nestable multiline comments |
|||
to use it for multi-line comments. For more about Pod, see |
|||
--/* .. --*/ Euphoria-compatibility-style nestable multiline comments/code |
|||
Synopsis 26: |
|||
http://perlcabal.org/syn/S26.html |
|||
=end comment</lang> |
|||
=={{header|PHP}}== |
=={{header|PHP}}== |
||
Single line comment: |
Single line comment: |
||
< |
<syntaxhighlight lang="php"># this is commented |
||
// this is commented</ |
// this is commented</syntaxhighlight> |
||
These may also be at the end of a line: |
These may also be at the end of a line: |
||
< |
<syntaxhighlight lang="php">$var = 1; # this is the comment part |
||
$var = 1; // this is the comment part</ |
$var = 1; // this is the comment part</syntaxhighlight> |
||
Basic syntax for multi-line comments: |
Basic syntax for multi-line comments: |
||
< |
<syntaxhighlight lang="php">/* |
||
Here are my comments |
Here are my comments |
||
this is multi-line |
this is multi-line |
||
*/</ |
*/</syntaxhighlight> |
||
Note that; it is more common to see phpDocumentor styled multi-lined comments: |
Note that; it is more common to see phpDocumentor styled multi-lined comments: |
||
< |
<syntaxhighlight lang="php">/** |
||
* phpdoc Comments |
* phpdoc Comments |
||
* @todo this is a todo stub |
* @todo this is a todo stub |
||
*/</ |
*/</syntaxhighlight> |
||
=={{header|Picat}}== |
|||
{{works with|Picat}} |
|||
<syntaxhighlight lang="picat"> |
|||
/* |
|||
* Multi-line comment |
|||
*/ |
|||
% Single-line Prolog-style comment |
|||
</syntaxhighlight> |
|||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |
||
< |
<syntaxhighlight lang="picolisp"># The rest of the line is ignored |
||
#{ |
#{ |
||
This is a |
This is a |
||
Line 1,056: | Line 2,387: | ||
This is typically used conditionally, with a read-macro expression like |
This is typically used conditionally, with a read-macro expression like |
||
`*Dbg |
`*Dbg |
||
so that this text is only read if in debugging mode.</ |
so that this text is only read if in debugging mode.</syntaxhighlight> |
||
=={{header|Pike}}== |
=={{header|Pike}}== |
||
< |
<syntaxhighlight lang="pike">// This is a comment. |
||
/* This is a |
/* This is a |
||
multi |
multi |
||
Line 1,065: | Line 2,396: | ||
comment */ |
comment */ |
||
int e = 3; // end-of-statement comment.</ |
int e = 3; // end-of-statement comment.</syntaxhighlight> |
||
=={{header|PL/I}}== |
|||
<syntaxhighlight lang="pli">/* This is a comment. */</syntaxhighlight> |
|||
<syntaxhighlight lang="pli">/* |
|||
This is a multiline comment. |
|||
*/</syntaxhighlight> |
|||
Note: In PL/I, comments cannot be nested. |
|||
=={{header|PL/SQL}}== |
|||
Single line comment: |
|||
<syntaxhighlight lang="plsql">--this is a single line comment</syntaxhighlight> |
|||
Multiline comment: |
|||
<syntaxhighlight lang="plsql">/* |
|||
this is a multiline |
|||
comment |
|||
*/</syntaxhighlight> |
|||
End of line comment: |
|||
<syntaxhighlight lang="plsql">v_var number; --this is an end of line comment</syntaxhighlight> |
|||
=={{header|Plain English}}== |
|||
<syntaxhighlight lang="plainenglish">\A comment like this lasts until the end of the line |
|||
Put 1 plus [there are inline comments too] 1 into a number.</syntaxhighlight> |
|||
=={{header|plainTeX}}== |
=={{header|plainTeX}}== |
||
Line 1,073: | Line 2,431: | ||
it; so the % starts a to-end-of-line comment in many TeX macro packages. |
it; so the % starts a to-end-of-line comment in many TeX macro packages. |
||
< |
<syntaxhighlight lang="tex">% this is a comment |
||
This is not.</ |
This is not.</syntaxhighlight> |
||
The final newline character is eaten and since it normally behaves like a space, the comment can |
The final newline character is eaten and since it normally behaves like a space, the comment can |
||
be used to hide the newline: |
be used to hide the newline: |
||
< |
<syntaxhighlight lang="tex">\def\firstpart#1{under#1} |
||
\def\secondpart{able} |
\def\secondpart{able} |
||
\def\complete{\firstpart% |
\def\complete{\firstpart{stand}% |
||
\secondpart} |
\secondpart} |
||
\complete</ |
\complete</syntaxhighlight> |
||
Outputs <tt>understandable</tt>; without % it would output <tt>understand able</tt>. |
Outputs <tt>understandable</tt>; without % it would output <tt>understand able</tt>. |
||
=={{header|PL/I}}== |
|||
<lang PL/I> |
|||
/* This is a comment. */ |
|||
</lang> |
|||
=={{header|PL/SQL}}== |
|||
Single line comment: |
|||
<lang plsql>--this is a single line comment</lang> |
|||
Multiline comment: |
|||
<lang plsql>/* |
|||
this is a multiline |
|||
comment |
|||
*/</lang> |
|||
End of line comment: |
|||
<lang plsql>v_var number; --this is an end of line comment</lang> |
|||
=={{header|Pop11}}== |
=={{header|Pop11}}== |
||
Line 1,114: | Line 2,451: | ||
begins with tree consecutive semicolons and ends at the end of line: |
begins with tree consecutive semicolons and ends at the end of line: |
||
< |
<syntaxhighlight lang="pop11">;;; This is a comment</syntaxhighlight> |
||
C-like comments may be multiline: |
C-like comments may be multiline: |
||
< |
<syntaxhighlight lang="pop11">/* First line |
||
Second line */</ |
Second line */</syntaxhighlight> |
||
C-like comments (unlike C) may be nested: |
C-like comments (unlike C) may be nested: |
||
< |
<syntaxhighlight lang="pop11">/* This is a comment /* containing nested comment */ */</syntaxhighlight> |
||
One can also use conditional compilation to comment out sections of code |
One can also use conditional compilation to comment out sections of code |
||
< |
<syntaxhighlight lang="pop11">#_IF false |
||
some code |
some code |
||
#_ENDIF</ |
#_ENDIF</syntaxhighlight> |
||
however, commented out part must consist of valid Pop11 tokens. In particular, C-like comments must balance and strings must be terminated. |
however, commented out part must consist of valid Pop11 tokens. In particular, C-like comments must balance and strings must be terminated. |
||
The following is an error: |
The following is an error: |
||
< |
<syntaxhighlight lang="pop11">#_IF false |
||
This w'ont work |
This w'ont work |
||
#_ENDIF</ |
#_ENDIF</syntaxhighlight> |
||
because apostrophe starts an unterminated string. |
because apostrophe starts an unterminated string. |
||
=={{header|PostScript}}== |
=={{header|PostScript}}== |
||
<lang> |
<syntaxhighlight lang="text"> |
||
%This is a legal comment in PostScript |
%This is a legal comment in PostScript |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|PowerShell}}== |
=={{header|PowerShell}}== |
||
<lang |
<syntaxhighlight lang="powershell"># single-line comment</syntaxhighlight> |
||
{{works with|PowerShell|2}} |
{{works with|PowerShell|2}} |
||
< |
<syntaxhighlight lang="powershell"><# multi-line |
||
comment #></ |
comment #></syntaxhighlight> |
||
=={{header| |
=={{header|Processing}}== |
||
<lang |
<syntaxhighlight lang="java">// a single-line comment |
||
<lang prolog>/* This is a |
|||
multi-line comment */</lang> |
|||
/* a multi-line |
|||
=={{header|Protium}}== |
|||
comment |
|||
Protium encloses all comments inside <@ OMT></@> (fixed length opcode) or <# OMIT></#> (variable length opcode) whether single- or multi- line. |
|||
*/ |
|||
<lang html> |
|||
<@ OMT>This is a |
|||
/* |
|||
multiline |
|||
comment |
* a multi-line comment |
||
* with some decorative stars |
|||
</lang> |
|||
*/ |
|||
OMT suppresses evaluation of everything contained. There are a variety of extra opcodes which can be used to control how OMT functions at run time. |
|||
// comment out a code line |
|||
// println("foo"); |
|||
// comment at the end of a line |
|||
println("foo bar"); // "baz"</syntaxhighlight> |
|||
==={{header|Processing Python mode}}=== |
|||
<syntaxhighlight lang="python"># a single-line comment |
|||
""" |
|||
Not strictly a comment, bare multi-line strings are used |
|||
in Python as multi-line comments. They are also used as |
|||
documentation strings or 'docstrings' when placed as the |
|||
first element inside function or class definitions. |
|||
""" |
|||
# comment out a code line |
|||
# println("foo") |
|||
# comment at the end of a line |
|||
println("foo bar") # "baz" |
|||
# there is no way to make an inline comment</syntaxhighlight> |
|||
=={{header|ProDOS}}== |
|||
I don't know why this is even a task because it should be included in any decent programming language. |
|||
<syntaxhighlight lang="prodos">IGNORELINE your text here</syntaxhighlight> |
|||
=={{header|ProgressBASIC}}== |
|||
10 REM I AM A COMMENT |
|||
=={{header|Prolog}}== |
|||
<syntaxhighlight lang="prolog">% this is a single-line comment that extends to the end of the line</syntaxhighlight> |
|||
<syntaxhighlight lang="prolog">/* This is a |
|||
multi-line comment */</syntaxhighlight> |
|||
=={{header|PureBasic}}== |
=={{header|PureBasic}}== |
||
PureBasic uses the ";" symbol to mark its comments. All text entered after ";" on a line is ignored by the compiler. |
PureBasic uses the ";" symbol to mark its comments. All text entered after ";" on a line is ignored by the compiler. |
||
< |
<syntaxhighlight lang="purebasic">;comments come after an unquoted semicolon and last until the end of the line |
||
foo = 5 ;This is a comment |
foo = 5 ;This is a comment |
||
c$ = ";This is not a comment" ;This is also a comment</ |
c$ = ";This is not a comment" ;This is also a comment</syntaxhighlight> |
||
=={{header|Python}}== |
=={{header|Python}}== |
||
Python uses the "#" symbol to mark it's comments. After placing a "#", everything to the right of it in that line will be ignored. |
Python uses the "#" symbol to mark it's comments. After placing a "#", everything to the right of it in that line will be ignored. |
||
<syntaxhighlight lang="python"># This is a comment |
|||
foo = 5 # You can also append comments to statements</syntaxhighlight> |
|||
Certain 'do nothing' expressions resemble comments |
Certain 'do nothing' expressions resemble comments |
||
<lang python>"""Un-assigned strings in triple-quotes might be used |
|||
<syntaxhighlight lang="python">"""Un-assigned strings in triple-quotes might be used |
|||
as multi-line comments |
as multi-line comments |
||
""" |
""" |
||
Line 1,185: | Line 2,559: | ||
of other quote marks without any need to \escape\ them using any special characters. They also may span multiple |
of other quote marks without any need to \escape\ them using any special characters. They also may span multiple |
||
lines without special escape characters. |
lines without special escape characters. |
||
'''</ |
'''</syntaxhighlight> |
||
Note that strings inserted among program statements in Python are treated as expressions (which, in void context, do nothing). Thus it's possible to "comment out" a section of code by simply wrapping the lines in "triple quotes" (three consecutive instances of quotation marks, or of apostrophes, and terminated with a matching set of the same). |
Note that strings inserted among program statements in Python are treated as expressions (which, in void context, do nothing). Thus it's possible to "comment out" a section of code by simply wrapping the lines in "triple quotes" (three consecutive instances of quotation marks, or of apostrophes, and terminated with a matching set of the same). Using unassigned strings as comments is frowned on and may also trigger certain linters. |
||
===Documentation Strings=== |
===Documentation Strings=== |
||
Python makes pervasive use of strings which immediately follow class and function definition statements, and those which appear as the first non-blank, non-comment line in any module or program file. These are called "documentation" strings or "docstrings" for short; and they are automatically associated with the '''__doc__''' attribute of the class, function, or module objects in which they are defined. Thus a fragment of code such as: |
Python makes pervasive use of strings which immediately follow class and function definition statements, and those which appear as the first non-blank, non-comment line in any module or program file. These are called "documentation" strings or "docstrings" for short; and they are automatically associated with the '''__doc__''' attribute of the class, function, or module objects in which they are defined. Thus a fragment of code such as: |
||
< |
<syntaxhighlight lang="python">#!/usr/bin/env python |
||
# Example of using doc strings |
# Example of using doc strings |
||
"""My Doc-string example""" |
"""My Doc-string example""" |
||
Line 1,208: | Line 2,582: | ||
print (Foo.__doc__) |
print (Foo.__doc__) |
||
print (Foo.__init__.__doc__) |
print (Foo.__init__.__doc__) |
||
print (bar.__doc__)</ |
print (bar.__doc__)</syntaxhighlight> |
||
Line 1,216: | Line 2,590: | ||
(As noted above extraneous strings interspersed throughout a Python source file can be used as comments, though this is rarely done in practice; only those strings which lexically follow the definition of a class, function, module or package are assigned to __doc__ attributes in their respective name spaces). |
(As noted above extraneous strings interspersed throughout a Python source file can be used as comments, though this is rarely done in practice; only those strings which lexically follow the definition of a class, function, module or package are assigned to __doc__ attributes in their respective name spaces). |
||
=={{header|Quackery}}== |
|||
<syntaxhighlight lang="quackery"> |
|||
( The word "(" is a compiler directive (a builder, |
|||
in Quackery jargon) that causes the compiler to |
|||
disregard everything until it encounters a ")" |
|||
preceded by whitespace. |
|||
If you require more than that, it is trivial to |
|||
define new comment builders... ) |
|||
[ behead carriage = until ] builds # |
|||
# Now the word "#" will cause the compiler to |
|||
# disregard everything from the "#" to the end of |
|||
# the line that it occurs on. |
|||
[ drop $ "" ] builds commentary |
|||
commentary |
|||
The word "commentary" will cause the compiler to |
|||
disregard everything that comes after it to the |
|||
end of the source string or file.</syntaxhighlight> |
|||
=={{header|QB64}}== |
|||
''CBTJD'': 2020/03/12 |
|||
<syntaxhighlight lang="qb64">REM This is a remark... |
|||
' This is also a remark... |
|||
IF a = 0 THEN REM (REM follows syntax rules) |
|||
IF a = 0 THEN '(apostrophe doesn't follow syntax rules, so use END IF after this) |
|||
END IF |
|||
'Metacommands such as $DYNAMIC and $INCLUDE use the REM (or apostrophe). |
|||
REM $STATIC 'arrays cannot be resized once dimensioned. |
|||
REM $DYNAMIC 'enables resizing of array dimensions with REDIM. |
|||
REM $INCLUDE: 'loads a reference file or library.</syntaxhighlight> |
|||
=={{header|R}}== |
=={{header|R}}== |
||
<lang |
<syntaxhighlight lang="rsplus"># end of line comment</syntaxhighlight> |
||
=={{header| |
=={{header|Racket}}== |
||
<syntaxhighlight lang="racket">; this is a to-end-of-line coment |
|||
#| balanced comment, #| can be nested |# |# |
|||
<lang raven> # this is a comment</lang> |
|||
#;(this expression is ignored) |
|||
#; ; the following expression is commented because of the #; in the beginning |
|||
=={{header|REALbasic}}== |
|||
(ignored)</syntaxhighlight> |
|||
=={{header|Raku}}== |
|||
<lang REALbasic>//Comments are denoted by a preceding double slash or or single quote |
|||
(formerly Perl 6) |
|||
'and continue to the end of the line. There are no multi-line comment blocks |
|||
Dim foo As Integer //Comments can also occupy the ends of code lines</lang> |
|||
'''Single-line comments''' |
|||
=={{header|REBOL}}== |
|||
A single-line comment starts with # and extends to the end of the line. |
|||
<lang REBOL> |
|||
; This is a line comment. |
|||
<syntaxhighlight lang="raku" line># the answer to everything |
|||
my $x = 42;</syntaxhighlight> |
|||
'''Multi-line comments''' |
|||
A multi-line comment starts with #` and followed by the commented text enclosed by bracketing characters (e.g., (), [], {}, 「」, etc.). |
|||
<syntaxhighlight lang="raku" line>#`( |
|||
Comments beginning with a backtick and one or more opening bracketing characters are embedded comments. |
|||
They can span more than one line… |
|||
) |
|||
my $y = #`{ …or only part of a line. } 3;</syntaxhighlight> |
|||
Multi-line comments can also be embedded into code. |
|||
<syntaxhighlight lang="raku" line>for #`(each element in) my @array { |
|||
say #`(or print element) $_ #`(with a newline); |
|||
}</syntaxhighlight> |
|||
Using more than one bracketing character lets you include an unmatched close bracket, as shown below. |
|||
<syntaxhighlight lang="raku" line>#`{{ |
|||
This close curly brace } won't terminate the comment early. |
|||
}}</syntaxhighlight> |
|||
'''Pod comments''' |
|||
<syntaxhighlight lang="raku" line>=begin comment |
|||
Pod is the successor to Perl 5's POD. This is the simplest way to use it for multi-line comments. |
|||
For more about Pod, see Pod: https://docs.perl6.org/language/pod |
|||
=end comment</syntaxhighlight> |
|||
Pod also provides declarator blocks which are special comments that attach to some source code and can be extracted as documentation. They are either #| or #= and must be immediately followed by either a space or an opening curly brace. In short, blocks starting with #| are attached to the code after them, and blocks starting with #= are attached to the code before them. |
|||
<syntaxhighlight lang="raku" line>#| Compute the distance between two points in the plane. |
|||
sub distance( |
|||
Rat \x1, #= First point's abscissa, |
|||
Rat \y1, #= First point's ordinate, |
|||
Rat \x2, #= Second point's abscissa, |
|||
Rat \y2, #= Second point's ordinate, |
|||
){ |
|||
return sqrt((x2 - x1)**2 + (y2 - y1)**2) |
|||
}</syntaxhighlight> |
|||
=={{header|Rapira}}== |
|||
Comments in Rapira are preceded by a backslash (\). |
|||
<syntaxhighlight lang="rapira">\ This is a Rapira comment.</syntaxhighlight> |
|||
=={{header|Raven}}== |
|||
<syntaxhighlight lang="raven"> # this is a comment</syntaxhighlight> |
|||
=={{header|REBOL}}== |
|||
<syntaxhighlight lang="rebol">; This is a line comment. |
|||
{ Multi-line strings can |
{ Multi-line strings can |
||
be used as comments |
be used as comments |
||
if you like } |
if you like } |
||
</syntaxhighlight> |
|||
</lang> |
|||
Functions have special commenting options which make them self documenting: |
Functions have special commenting options which make them self documenting: |
||
<syntaxhighlight lang="rebol"> |
|||
<lang REBOL> |
|||
plus2: func [ |
plus2: func [ |
||
"Adds two to a number." |
"Adds two to a number." |
||
Line 1,249: | Line 2,721: | ||
n + 2 |
n + 2 |
||
] |
] |
||
</syntaxhighlight> |
|||
</lang> |
|||
If you say "help plus2" at REBOL's REPL, you'll get this help information: |
If you say "help plus2" at REBOL's REPL, you'll get this help information: |
||
Line 1,262: | Line 2,734: | ||
ARGUMENTS: |
ARGUMENTS: |
||
n -- The number to increase. (Type: number) |
n -- The number to increase. (Type: number) |
||
=={{header|Relation}}== |
|||
<syntaxhighlight lang="relation"> |
|||
// This is a valid comment |
|||
// A space is needed after the double slash |
|||
</syntaxhighlight> |
|||
=={{header|Retro}}== |
=={{header|Retro}}== |
||
< |
<syntaxhighlight lang="retro">( comments are placed between parentheses. A space must follow the opening parenthesis. )</syntaxhighlight> |
||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
It should be noted that comments in the REXX language support '''nested''' comments, so comments aren't totally ignored by the REXX interpreter (and compiler). |
|||
<lang rexx>/* everything |
|||
between a climbstar and a starclimb is a comment. |
|||
/* Nested comments */ |
|||
can be used |
|||
in Rexx */ |
|||
REXX comments are scanned and preserved for use by the '''sourceline''' BIF. [The '''sourceline''' BIF allows the retrieval of any or all lines of source (of the REXX program).] |
|||
hour = 12 /* high noon */ |
|||
midnight=00 /*first hour of the day*/ |
|||
Also, redundant blanks are removed and processed/shown for various '''trace''' options ('''trace''' is a REXX statement that may show various interpretation/execution stages of REXX statements (clauses, values, etc.), including comments and also blank lines). The '''trace''' statement is also used for interactive debugging. |
|||
Nested comments must have matching delimiters, so the contents of the comments can't just be willy-nilly characters. |
|||
/*Note: |
|||
climbStar= /* (slash asterisk) |
|||
starClimb= */ (asterisk slash) */ |
|||
</lang> |
|||
{{works with|oorexx}} |
|||
<lang rexx>-- this type of comment works only in ooREXX |
|||
Also, some REXX interpreters show the comment (if part of a REXX statement) as part of the information displayed when (if) a '''syntax''' error occurs and an informative error message is generated. For instance, in the program (named c:\COMMENTD.REX): |
|||
hour = 0 -- midnight |
|||
<syntaxhighlight lang="rexx">/*REXX program that demonstrates what happens when dividing by zero. */ |
|||
</lang> |
|||
y=7 |
|||
say 44 / (7-y) /* divide by some strange thingy.*/</syntaxhighlight> |
|||
'''output''' when using the Regina REXX interpreter:' |
|||
<pre> |
|||
3 +++ say 44 / (7-y) /* divide by some strange thingy.*/ |
|||
Error 42 running "c:\COMMENTD.REX", line 3: Arithmetic overflow/underflow |
|||
Error 42.3: Arithmetic overflow; divisor must not be zero |
|||
</pre> |
|||
'''output''' when using the R4 REXX interpreter:' |
|||
<pre> |
|||
Error 42 : Arithmetic overflow/underflow (SYNTAX) |
|||
Information: Divide by zero |
|||
Error occurred in statement# 3 |
|||
Statement source: say 44/(7-y) |
|||
Statement context: c:\commentdv.rex, procedure: commentdv |
|||
</pre> |
|||
'''output''' when using the Personal REXX interpreter:' |
|||
<pre> |
|||
3 +++ say 44 / (7-y) /* divide by some strange thingy.*/ |
|||
Error 42 on line 3 of C:\COMMENTD.REX: Arithmetic overflow/underflow |
|||
</pre> |
|||
<br>The '''REXX''' language was heavily modeled after '''PL/I''', both languages have the same comment construct, but '''PL/I''' doesn't support nested comments. |
|||
<br>Nested comments allow an easy way to comment large chunks of code where the commented-out code has its own comments. |
|||
<syntaxhighlight lang="rexx">/*REXX program to demonstrate various uses and types of comments. */ |
|||
/* everything between a "climbstar" and a "starclimb" (exclusive of literals) is |
|||
a comment. |
|||
climbstar = /* [slash-asterisk] |
|||
starclimb = */ [asterisk-slash] |
|||
/* this is a nested comment, by gum! */ |
|||
/*so is this*/ |
|||
Also, REXX comments can span multiple records. |
|||
There can be no intervening character between the slash and asterisk (or |
|||
the asterisk and slash). These two joined characters cannot be separated |
|||
via a continued line, as in the manner of: |
|||
say 'If I were two─faced,' , |
|||
'would I be wearing this one?' , |
|||
' --- Abraham Lincoln' |
|||
Here comes the thingy that ends this REXX comment. ───┐ |
|||
│ |
|||
│ |
|||
↓ |
|||
*/ |
|||
hour = 12 /*high noon */ |
|||
midnight = 00 /*first hour of the day */ |
|||
suits = 1234 /*card suits: ♥ ♦ ♣ ♠ */ |
|||
hutchHdr = '/*' |
|||
hutchEnd = "*/" |
|||
/* the previous two "hutch" assignments aren't |
|||
the start nor the end of a REXX comment. */ |
|||
x=1000000 ** /*¡big power!*/ 1000 |
|||
/*not a real good place for a comment (above), |
|||
but essentially, a REXX comment can be |
|||
anywhere whitespace is allowed. */</syntaxhighlight> |
|||
A Classic REXX implementation (e.g. Regina) also allow line comments which start with a '''--''' sequence and extend to the end of the line: |
|||
[Note: Regina REXX releases since 3.4 allow this type of single-line comment ''only'' if the option '''Single_Line_comments''' isn't present in the '''REGINA_OPTIONS''' environmental variable. So, Regina ''may'' allow the use of single-line comments, depending upon which release is being used. That is to say, one can't depend (or assume) that the Regina extension (of single-line comments) for the aforementioned option will be or not be present (supported and/or allowed) in the environment being used]. Which means one could set this option to their preference if using Regina REXX later than version 3.3. |
|||
Since Single-Line comments aren't part of the ANSI standard nor a part of the Classic REXX language, the use of which would make the REXX code <u>non-portable.</u>] |
|||
<!-- |
|||
The default is apparently that the nice -- feature (which I dont have on TSO) is available. |
|||
That comment should probably be moved to the discussion page. One can't assume that a particular person (or administrator?) has set the environmental variable (which may be controlled or restricted by policy -- this is especially true of company-owned PCs, many companies place ''severe'' restrictions about what users are allowed to change in the environment -- if changes are allowed at all, let alone installing software); it may already have been configured/installed/copied that way by someone else (such as a network or system administrator). It is important to recognize that this extension may or may not be available, depending on an environmental variable setting, and/or depending upon which version of Regina is being used, and it can't be assumed that the latest version of the Regina REXX interpreter has been installed or being used. During regression testing, many possible versions (of Regina) would be used. Not all programmers think that feature is nice, which is quite subjective, and that is one reason people refrain from praising certain extensions -- one reason is that it breaks the ASCII standard of allowing multiple (unary) negative prefixes. Furthermore, not all (older) versions of Regina have this extension, some people have to use an older version of Regina for various reasons. |
|||
The fact that Regina REXX is the only Classic REXX to support this feature makes the use of single-line comments non-portable (to other Classic REXX interpreters). -- ~~~~ |
|||
--> |
|||
<syntaxhighlight lang="rexx">-- A REXX line comment (maybe) |
|||
say "something" -- another line comment (maybe)</syntaxhighlight> |
|||
It should be noted that the above type of comments are not part of Classic REXX, nor are they described nor sanctioned in the REXX ANSI standard. |
|||
=={{header|Ring}}== |
|||
in Ring language we can use // or # for one line comments: |
|||
<syntaxhighlight lang="ring"> |
|||
//this is a single line comment |
|||
#this also a single line comment! |
|||
</syntaxhighlight> |
|||
and for multi-line comments we use /* */: |
|||
<syntaxhighlight lang="ring"> |
|||
/*This is a multi-line |
|||
comment that will be completely |
|||
ignored by the compiler/interpreter |
|||
*/ |
|||
</syntaxhighlight> |
|||
=={{header|RLaB}}== |
=={{header|RLaB}}== |
||
Line 1,292: | Line 2,864: | ||
RLaB only has single line comment indicator, as in following examples |
RLaB only has single line comment indicator, as in following examples |
||
<syntaxhighlight lang="rlab"> |
|||
<lang RLaB> |
|||
x = "code" # I am a comment |
x = "code" # I am a comment |
||
x = "code" // Here I comment thee |
x = "code" // Here I comment thee |
||
# matlab-like document line |
# matlab-like document line |
||
// C++ like document line |
// C++ like document line |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Robotic}}== |
|||
Comments can only be created in one way: |
|||
<syntaxhighlight lang="robotic"> |
|||
. "This is a comment line" |
|||
. "Print Hello world" |
|||
* "Hello world." |
|||
. "This is the only way to comment a line in Robotic" |
|||
</syntaxhighlight> |
|||
Although these are comments, the interpreter doesn't completely ignore it. For one, the code speed can be affected if they are ever encountered. Also, if an @ character exists at the beginning of the comment line, then the rest of the string after it is now the Robot's new name (there is a 14 character limit). |
|||
Example of changing the robot's name: |
|||
<syntaxhighlight lang="robotic"> |
|||
. "@NewRobotName" |
|||
</syntaxhighlight> |
|||
This would then change the robot's name from whatever it was before to "NewRobotName" instead. |
|||
=={{header|Rockstar}}== |
|||
<syntaxhighlight lang="rockstar">Rockstar is cool. |
|||
(Rockstars don't like comments, but if you really really want to, you write them in parentheses and they are believed to be multiline. In fact, parentheses are just the comment symbols, so you can't even use parentheses in math, so if you want the addition to happen before the multiplication, do the addition and assign it to a variable. And by the way, the Rockstar is cool line assigned the number 4 to the variable Rockstar, because cool is four letters and all that. And this comment has gone on way too long for a language with a developer community that hates comments.) |
|||
Shout Rockstar. |
|||
(Might as well put that number 4 on the screen.)</syntaxhighlight> |
|||
=={{header|RPL}}== |
|||
Although its code can sometimes be difficult to read due to stack operations, basic RPL does not provide any functionality to comment out. The only solution is then to insert strings and delete them immediately, such as: |
|||
≪ |
|||
SWAP - <span style="color:grey">"swap the first 2 levels and subtract" DROP</span> |
|||
≫ |
|||
From 1993, comments can be added in a source code written with a text editor on a computer, starting with an @ and ending by either another @ or a newline character, before transfer to and compilation by the calculator. The compilation step removes all comments. |
|||
≪ |
|||
SWAP - <span style="color:grey">@ swap the first 2 levels and subtract </span> |
|||
≫ |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
< |
<syntaxhighlight lang="ruby">x = "code" # I am a comment |
||
=begin hello |
=begin hello |
||
I a POD documentation comment like Perl |
I a POD documentation comment like Perl |
||
=end puts "code"</ |
=end puts "code"</syntaxhighlight> |
||
=={{header|Run BASIC}}== |
|||
Comments have a ' (single quote) or REM for remarks |
|||
<syntaxhighlight lang="runbasic">'This is a comment |
|||
REM This is a comment |
|||
print "Notice comment at the end of the line." 'This is a comment |
|||
print "Also notice this comment at the end of the line." : REM This is a comment |
|||
</syntaxhighlight> |
|||
=={{header|Rust}}== |
|||
<syntaxhighlight lang="rust">// A single line comment |
|||
/* |
|||
This is a multi-line (aka block) comment |
|||
/* |
|||
containing nested multi-line comment |
|||
(nesting supported since 0.9-pre https://github.com/mozilla/rust/issues/9468) |
|||
*/ |
|||
*/ |
|||
/// Outer single line Rustdoc comments apply to the next item. |
|||
/** |
|||
Outer multi-line Rustdoc comments. |
|||
* Leading asterisk (*) in multi-line Rustdoc comments |
|||
* is not considered to be part of the comment text, |
|||
* blanks and tabs preceding the initial asterisk (*) are also stripped. |
|||
*/ |
|||
fn example() { |
|||
//! Inner single line Rustdoc comments apply to their enclosing item. |
|||
/*! |
|||
Inner multi-line Rustdoc comments. |
|||
See also https://github.com/mozilla/rust/wiki/Doc-using-rustdoc |
|||
*/ |
|||
} |
|||
#[doc = "Unsugared outer Rustdoc comments. |
|||
(outer attributes are not terminated by a semi-colon)"] |
|||
fn example() { |
|||
#[doc = "Unsugared inner Rustdoc comments. |
|||
(inner attributes are terminated by a semi-colon) |
|||
See also https://github.com/mozilla/rust/blob/master/doc/rust.md#attributes"]; |
|||
}</syntaxhighlight> |
|||
=={{header|SAS}}== |
|||
<syntaxhighlight lang="sas">/* comment */ |
|||
*another comment; |
|||
* both |
|||
may |
|||
be |
|||
multiline;</syntaxhighlight> |
|||
=={{header|Sather}}== |
=={{header|Sather}}== |
||
<lang |
<syntaxhighlight lang="sather">-- a single line comment</syntaxhighlight> |
||
=={{header|S-BASIC}}== |
|||
<syntaxhighlight lang="BASIC"> |
|||
rem S-BASIC of course allows traditional BASIC-style comments |
|||
comment |
|||
In addition to the single-line REM statement, S-BASIC |
|||
also supports multiline comments using COMMENT...END. |
|||
Note that the terminating END must be the first token on |
|||
a line of its own. |
|||
end |
|||
comment |
|||
When declaring a group of variables, S-BASIC allows |
|||
a semi-colon, instead of the normal comma, as a separator, |
|||
in which event an explanatory comment can follow the |
|||
semi-colon and is ignored by the compiler. |
|||
end |
|||
var n ; number of payments over life of loan |
|||
ppy ; payments per year |
|||
apr ; annual interest rate as a decimal |
|||
amt ; principal amount of loan |
|||
pmt ; amount of periodic payment |
|||
= real |
|||
comment |
|||
Finally, although statements in S-BASIC are normally terminated |
|||
by an end-of-line, any logical statement can be continued on to |
|||
the following physical line with a backslash, in which event |
|||
anything after the backslash is ignored and can be used for |
|||
a comment. |
|||
end |
|||
if amt = 0 then \ user forgot to enter a value |
|||
print "Must specify a loan amount!" |
|||
end |
|||
</syntaxhighlight> |
|||
=={{header|Scala}}== |
=={{header|Scala}}== |
||
< |
<syntaxhighlight lang="scala">// A single line comment |
||
/* A multi-line |
/* A multi-line |
||
comment */</ |
comment */</syntaxhighlight> |
||
=={{header|Scheme}}== |
=={{header|Scheme}}== |
||
< |
<syntaxhighlight lang="scheme">; Basically the same as Common Lisp |
||
; While R5RS does not provide block comments, they are defined in SRFI-30, as in Common Lisp : |
; While R5RS does not provide block comments, they are defined in SRFI-30, as in Common Lisp : |
||
Line 1,327: | Line 3,032: | ||
; See http://srfi.schemers.org/srfi-30/srfi-30.html |
; See http://srfi.schemers.org/srfi-30/srfi-30.html |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Scilab}}== |
|||
Specify a comment starting with // to the end of line |
|||
<syntaxhighlight lang="text">// this is a comment |
|||
i=i+1 // this is a comment</syntaxhighlight> |
|||
=={{header|sed}}== |
|||
<syntaxhighlight lang="sed"># a single line comment</syntaxhighlight> |
|||
=={{header|Seed7}}== |
=={{header|Seed7}}== |
||
< |
<syntaxhighlight lang="seed7"># A single line comment |
||
(* A multi-line |
(* A multi-line |
||
Line 1,337: | Line 3,050: | ||
(* In Seed7, |
(* In Seed7, |
||
(* comments can be nested. *) *)</ |
(* comments can be nested. *) *)</syntaxhighlight> |
||
=={{header|SenseTalk}}== |
|||
<syntaxhighlight lang="sensetalk"> |
|||
# Hashtag is a comment |
|||
-- Dash dash is another comment |
|||
// Slash slash is yet another comment |
|||
— Alt/Option + Underscore creates an m-dash comment |
|||
(* Parentheses and star is used for commenting |
|||
blocks of code (* and can be nested *) *) |
|||
set foo to true // all comments can append to statements |
|||
</syntaxhighlight> |
|||
=={{header|Set lang}}== |
|||
<syntaxhighlight lang="set_lang">> Comments start where a > (greater than symbol) starts |
|||
set a 0 > Comments may start after a Set command</syntaxhighlight> |
|||
=={{header|SETL}}== |
|||
<syntaxhighlight lang="setl">print("This is not a comment"); -- This is a comment |
|||
$ For nostalgic reasons, this is also a comment.</syntaxhighlight> |
|||
=={{header|Sidef}}== |
|||
Single line comment |
|||
<syntaxhighlight lang="ruby"># this is commented</syntaxhighlight> |
|||
These may also be at the end of a line |
|||
<syntaxhighlight lang="ruby">var i = 1; # this is the comment part</syntaxhighlight> |
|||
Embedded comments |
|||
<syntaxhighlight lang="ruby">var distance #`{in meters} = (30 #`{meters} * 100 #`{seconds}); |
|||
say distance; # prints: 3000</syntaxhighlight> |
|||
Multi-line comments |
|||
<syntaxhighlight lang="ruby">/* |
|||
This is a multi-line comment |
|||
*/</syntaxhighlight> |
|||
=={{header|Simula}}== |
|||
The same as Algol 60: |
|||
<syntaxhighlight lang="text">COMMENT This is a comment for Simula 67;</syntaxhighlight> |
|||
And an new form: |
|||
<syntaxhighlight lang="text">!This is a comment for Simula 67;</syntaxhighlight> |
|||
'''Pitfall''': it's ''not'' easy to ''comment-out'' parts of code: |
|||
<syntaxhighlight lang="simula">!OutText("Dying."); !Outimage; !terminate_program;</syntaxhighlight> |
|||
=={{header|Slate}}== |
=={{header|Slate}}== |
||
<syntaxhighlight lang="slate">"basically the same as smalltalk"</syntaxhighlight> |
|||
<lang slate>"basically the same as smalltalk"</lang> |
|||
=={{header|Smalltalk}}== |
=={{header|Smalltalk}}== |
||
< |
<syntaxhighlight lang="smalltalk">"Comments traditionally are in double quotes." |
||
"Multiline comments are also supported. |
"Multiline comments are also supported. |
||
Comments are saved as metadata along with the source to a method. |
Comments are saved as metadata along with the source to a method. |
||
A comment just after a method signature is often given to explain the |
A comment just after a method signature is often given to explain the |
||
usage of the method. The class browser may display such comments |
usage of the method. The class browser may display such comments |
||
specially."</ |
specially."</syntaxhighlight> |
||
=={{header|smart BASIC}}== |
|||
<syntaxhighlight lang="text">'Single line comments are preceded by a single quote or the command REM |
|||
PRINT "Hello" 'Single line comments may follow code |
|||
PRINT "Hello" REM You can also use the command REM following code |
|||
/* |
|||
Multi-line comments |
|||
are surrounded by |
|||
mirrored slash |
|||
and asterisk |
|||
*/ |
|||
/*Multi-line comments do not have to actually have multiple lines*/ |
|||
/* Spaces before or after comment bounds are optional.*/ |
|||
/* A comment can also follow another comment */ 'Like this |
|||
Some programmers like to do this to allow for /* Procedural comments */ followed by 'Programmer's notes.</syntaxhighlight> |
|||
=={{header|SNOBOL4}}== |
=={{header|SNOBOL4}}== |
||
<syntaxhighlight lang="snobol4"> |
|||
<lang SNOBOL4> |
|||
* An asterisk in column 1 is the standard Snobol comment |
* An asterisk in column 1 is the standard Snobol comment |
||
* mechanism, marking the entire line as a comment. There |
* mechanism, marking the entire line as a comment. There |
||
Line 1,374: | Line 3,151: | ||
END |
END |
||
Any text after the required END label is ignored.</ |
Any text after the required END label is ignored.</syntaxhighlight> |
||
=={{header|SNUSP}}== |
=={{header|SNUSP}}== |
||
Line 1,383: | Line 3,160: | ||
As a matter of convention, the characters '=' and '|' are used for spacing to indicate horizontal and vertical flow of control, respectively. |
As a matter of convention, the characters '=' and '|' are used for spacing to indicate horizontal and vertical flow of control, respectively. |
||
=={{header|SPL}}== |
|||
<syntaxhighlight lang="spl">'This is single-line comment |
|||
''This is |
|||
multiline comment''</syntaxhighlight> |
|||
=={{header|SQL}}== |
|||
The double hyphen ( -- ) is used to include a comment on an SQL statement. |
|||
The comment appears on the same line as the statement: |
|||
<syntaxhighlight lang="sql">SELECT * FROM mytable -- Selects all columns and rows</syntaxhighlight> |
|||
or before: |
|||
<syntaxhighlight lang="sql">-- Selects all columns and rows |
|||
SELECT * FROM mytable </syntaxhighlight> |
|||
or after: |
|||
<syntaxhighlight lang="sql">SELECT * FROM mytable |
|||
-- Selects all columns and rows</syntaxhighlight> |
|||
=={{header|SQL PL}}== |
|||
{{works with|Db2 LUW}} |
|||
Single line comment: |
|||
<syntaxhighlight lang="sql pl"> |
|||
--This is a single line comment. |
|||
</syntaxhighlight> |
|||
Multiline comment: |
|||
<syntaxhighlight lang="sql pl"> |
|||
/* This is |
|||
a multiline |
|||
comment */ |
|||
</syntaxhighlight> |
|||
Another way to do multiline comments |
|||
<syntaxhighlight lang="sql pl"> |
|||
(= This is |
|||
a multiline |
|||
comment =) |
|||
</syntaxhighlight> |
|||
End of line comment: |
|||
<syntaxhighlight lang="sql pl"> |
|||
declare myvar number; --This is an end of line comment. |
|||
</syntaxhighlight> |
|||
Comments work the same as in [[SQL]]. |
|||
=={{header|Squirrel}}== |
|||
<syntaxhighlight lang="squirrel">//this is a single line comment |
|||
#this is also a single line comment |
|||
/* |
|||
this is a multi-line comment |
|||
*/</syntaxhighlight> |
|||
=={{header|SSEM}}== |
|||
The SSEM can only be programmed in pure binary, by setting front panel switches: the concepts of "text" and "source file" (both mentioned in the specification) are therefore not directly applicable to it. If binary numbers have any mnemonic or explanatory value for you, however, there is a way of including information in your program that the computer will ignore. This is a direct result of the machine's rather poor code density. Each 32-bit instruction word consists of (a) a five-bit address field giving the operand, (b) eight unused bits, (c) a three-bit instruction field giving the operation to be performed, and (d) sixteen more unused bits. If the instruction field is set to <tt>011 Test</tt> or <tt>111 Stop</tt>, even the address field is unused. In the case of a <tt>Sub.</tt> instruction, finally, the leftmost bit of the instruction field is disregarded: <tt>001</tt> and <tt>101</tt> both mean "subtract". We therefore have at least 24 and sometimes 25 or 29 bits in each instruction that we can, if we like, use for comments. The word |
|||
<syntaxhighlight lang="ssem">00101010010001000100100100001100</syntaxhighlight> |
|||
will be understood by the machine as <tt>Add 20 to CI</tt>, a normal instruction. But it also fits four comment characters into the unused bits, employing a simple five-bit encoding where <tt>A</tt>=0 and <tt>Z</tt>=25. The instruction breaks down as follows: |
|||
<tt>00101 -- </tt>address field = 20 |
|||
<tt>01001 -- </tt>"comment" field = 18 |
|||
<tt>000 -- </tt>three unused bits |
|||
<tt>100 -- </tt>instruction field = <tt>Add to CI</tt> |
|||
<tt>01001 -- </tt>"comment" field = 18 |
|||
<tt>00100 -- </tt>"comment" field = 4 |
|||
<tt>01100 -- </tt>"comment" field = 12 |
|||
<tt>0 -- </tt>unused bit |
|||
Applying our simple alphabetic encoding, we see that the "spare" bits spell out 18, 18, 4, 12 = S, S, E, M. |
|||
More realistically, you can include comments when you are drafting your program using mnemonic notation and then simply leave the comments out when it comes time to toggle the program in. |
|||
=={{header|Standard ML}}== |
=={{header|Standard ML}}== |
||
< |
<syntaxhighlight lang="sml">(* This a comment |
||
(* containing nested comment *) |
(* containing nested comment *) |
||
*)</ |
*)</syntaxhighlight> |
||
=={{header|Stata}}== |
|||
<syntaxhighlight lang="stata">* Line comment: must be used at the beginning of a line (does not work in Mata) |
|||
// Line comment until the end of the line |
|||
/* Multiline comment |
|||
*/</syntaxhighlight> |
|||
=={{header|SuperTalk}}== |
|||
<syntaxhighlight lang="supertalk">-- This is a comment</syntaxhighlight> |
|||
=={{header|Swift}}== |
|||
<syntaxhighlight lang="swift">// this is a single line comment |
|||
/* This a block comment |
|||
/* containing nested comment */ |
|||
*/ |
|||
///This is a documentation comment |
|||
/** |
|||
This is a documentation block comment |
|||
*/</syntaxhighlight> |
|||
=={{header|Symsyn}}== |
|||
<syntaxhighlight lang="symsyn"> |
|||
| This is a comment |
|||
</syntaxhighlight> |
|||
=={{header|Tcl}}== |
=={{header|Tcl}}== |
||
Line 1,394: | Line 3,284: | ||
Tcl follows the usual scripting language rules: a comment starts at a "#" symbol, which can be placed after a command if that is terminated by a semicolon: |
Tcl follows the usual scripting language rules: a comment starts at a "#" symbol, which can be placed after a command if that is terminated by a semicolon: |
||
< |
<syntaxhighlight lang="tcl"># comment on a line by itself. The next is a command by itself: |
||
set var1 $value1 |
set var1 $value1 |
||
set var2 $value2 ; # comment that follows a line of code</ |
set var2 $value2 ; # comment that follows a line of code</syntaxhighlight> |
||
The reason for the need for a semi-colon on a trailing comment is this: |
The reason for the need for a semi-colon on a trailing comment is this: |
||
Line 1,404: | Line 3,294: | ||
The "#" symbol has no special meaning if it is not where a command would appear -- it's just data. (Syntax highlighters often get this wrong.) |
The "#" symbol has no special meaning if it is not where a command would appear -- it's just data. (Syntax highlighters often get this wrong.) |
||
< |
<syntaxhighlight lang="tcl">set aList {foo} |
||
lappend aList # bar |
lappend aList # bar |
||
puts $aList ;# ==> prints "foo # bar" |
puts $aList ;# ==> prints "foo # bar" |
||
puts [llength $aList] ;# ==> 3</ |
puts [llength $aList] ;# ==> 3</syntaxhighlight> |
||
TCL has no native multi-line comment format. However, in most circumstances, a multi-line comment can be faked by wrapping it within a block that will never be executed: |
TCL has no native multi-line comment format. However, in most circumstances, a multi-line comment can be faked by wrapping it within a block that will never be executed: |
||
< |
<syntaxhighlight lang="tcl">if 0 { |
||
Comments... |
Comments... |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Tern}}== |
|||
:''See [[Comments#Java|Java]]'' |
|||
=={{header|TI-83 BASIC}}== |
=={{header|TI-83 BASIC}}== |
||
Line 1,419: | Line 3,312: | ||
One common approach is to put the comment in a string which is not stored anywhere: |
One common approach is to put the comment in a string which is not stored anywhere: |
||
< |
<syntaxhighlight lang="ti83b">:"THIS IS A COMMENT</syntaxhighlight> |
||
However this will change the Ans variable. |
However this will change the Ans variable. |
||
This approach, while messier, does not affect the Ans variable: |
This approach, while messier, does not affect the Ans variable: |
||
< |
<syntaxhighlight lang="ti83b">:If 0 |
||
:THIS IS A COMMENT</ |
:THIS IS A COMMENT</syntaxhighlight> |
||
=={{header|TI-89 BASIC}}== |
=={{header|TI-89 BASIC}}== |
||
< |
<syntaxhighlight lang="ti89b">© This is a comment. Everything from © to the end of the line is ignored.</syntaxhighlight> |
||
=={{header|Tiny BASIC}}== |
|||
<syntaxhighlight lang="tiny basic"> |
|||
10 REM this is a comment |
|||
20 |
|||
40 REM from above you can see that line numbers with no statement |
|||
50 REM and blank lines also are ignored |
|||
</syntaxhighlight> |
|||
=={{header|Toka}}== |
=={{header|Toka}}== |
||
Line 1,436: | Line 3,338: | ||
a line, the shebang is normally used: |
a line, the shebang is normally used: |
||
< |
<syntaxhighlight lang="toka">#! Everything on this line (after the shebang to the left) will be ignored.</syntaxhighlight> |
||
The shebang comments can not be used inside of functions. |
The shebang comments can not be used inside of functions. |
||
Line 1,442: | Line 3,344: | ||
In addition, Toka also accepts parenthetical comments. These are enclosed in parenthesis, and are often used for stack comments or comments inside functions. |
In addition, Toka also accepts parenthetical comments. These are enclosed in parenthesis, and are often used for stack comments or comments inside functions. |
||
< |
<syntaxhighlight lang="toka">[ ( a b -- c ) |
||
... ] is myword</ |
... ] is myword</syntaxhighlight> |
||
In addition, parenthetical comments can span multiple lines. |
In addition, parenthetical comments can span multiple lines. |
||
< |
<syntaxhighlight lang="toka">( This is a |
||
simple, multi-line |
simple, multi-line |
||
comment )</ |
comment )</syntaxhighlight> |
||
Since comments are provided by actual functions, the comment function must be whitespace delimited, just as with all other functions in Toka. |
Since comments are provided by actual functions, the comment function must be whitespace delimited, just as with all other functions in Toka. |
||
Line 1,455: | Line 3,357: | ||
A final way to include text in a file is to mark a false ending with '''end.''' |
A final way to include text in a file is to mark a false ending with '''end.''' |
||
< |
<syntaxhighlight lang="toka">... code .... |
||
end. |
end. |
||
Nothing following the end. will be evaluated by Toka.</ |
Nothing following the end. will be evaluated by Toka.</syntaxhighlight> |
||
=={{header|TorqueScript}}== |
|||
<syntaxhighlight lang="torquescript">//This is a one line comment. There are no other commenting options in TorqueScript.</syntaxhighlight> |
|||
=={{header|TPP}}== |
|||
<syntaxhighlight lang="tpp">--## comments are prefixed with a long handed double paintbrush</syntaxhighlight> |
|||
=={{header|Transd}}== |
|||
<syntaxhighlight lang="scheme">// This is a line comment. |
|||
/* This is a single line block comment.*/ |
|||
/* This is |
|||
a multi-line |
|||
block comment.*/ |
|||
</syntaxhighlight> |
|||
=={{header|TUSCRIPT}}== |
=={{header|TUSCRIPT}}== |
||
< |
<syntaxhighlight lang="tuscript"> |
||
$$ MODE TUSCRIPT |
$$ MODE TUSCRIPT |
||
- This is a comment |
- This is a comment |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|TXR}}== |
|||
<syntaxhighlight lang="txr">@# old-style comment to end of line |
|||
@; new-style comment to end of line |
|||
@(bind a ; comment within expression |
|||
"foo")</syntaxhighlight> |
|||
=={{header|UNIX Shell}}== |
=={{header|UNIX Shell}}== |
||
{{works with|Bourne Shell}} |
{{works with|Bourne Shell}} |
||
{{works with|Korn Shell}} |
|||
< |
<syntaxhighlight lang="bash">#!/bin/sh |
||
# A leading hash symbol begins a comment. |
# A leading hash symbol begins a comment. |
||
echo "Hello" # Comments can appear after a statement. |
echo "Hello" # Comments can appear after a statement. |
||
# The hash symbol must be at the beginning of a word. |
# The hash symbol must be at the beginning of a word. |
||
echo |
echo This_Is#Not_A_Comment |
||
#Comment</ |
#Comment</syntaxhighlight> |
||
==={{header|C Shell}}=== |
==={{header|C Shell}}=== |
||
< |
<syntaxhighlight lang="csh">#!/bin/csh -f |
||
# C Shell has a similar comment syntax, but only allows comments in a |
# C Shell has a similar comment syntax, but only allows comments in a |
||
# script file, not in terminal input. |
# script file, not in terminal input. |
||
echo Hello#With C Shell, the hash can also be in the middle of a word.</ |
echo Hello#With C Shell, the hash can also be in the middle of a word.</syntaxhighlight> |
||
==={{header|es}}=== |
|||
<syntaxhighlight lang="es"># Comments in es (extensible shell) look like those of other shells. |
|||
echo Hello#With es, the hash can also be in the middle of a word.</syntaxhighlight> |
|||
=={{header|Unlambda}}== |
=={{header|Unlambda}}== |
||
Line 1,499: | Line 3,431: | ||
`.ai |
`.ai |
||
</pre> |
</pre> |
||
=={{header|Ursa}}== |
|||
Comments in Ursa must be on a single line, and are denoted by a # |
|||
<syntaxhighlight lang="ursa"># this is a comment |
|||
# this is another comment |
|||
</syntaxhighlight> |
|||
=={{header|Ursala}}== |
=={{header|Ursala}}== |
||
There are lots of ways to have comments in Ursala. |
There are lots of ways to have comments in Ursala. |
||
Here are the conventional ones. |
Here are the conventional ones. |
||
< |
<syntaxhighlight lang="ursala"># this is single line a comment |
||
# this is a\ |
# this is a\ |
||
Line 1,519: | Line 3,457: | ||
### |
### |
||
The whole rest of the file after three hashes |
The whole rest of the file after three hashes |
||
is a comment.</ |
is a comment.</syntaxhighlight> |
||
=== Commenting out code === |
=== Commenting out code === |
||
Line 1,526: | Line 3,464: | ||
An individual item of a syntactically correct list or aggregate is commented |
An individual item of a syntactically correct list or aggregate is commented |
||
out like this. |
out like this. |
||
< |
<syntaxhighlight lang="ursala">x = <1,## 2,3></syntaxhighlight> |
||
The 2 is ignored but 1 and 3 aren't. This also works with |
The 2 is ignored but 1 and 3 aren't. This also works with |
||
nested aggregates and multiple lines. |
nested aggregates and multiple lines. |
||
<syntaxhighlight lang="ursala">a = |
|||
<lang Ursala>a = |
|||
< |
< |
||
Line 1,538: | Line 3,476: | ||
'not', |
'not', |
||
'to', |
'to', |
||
## 'be'></ |
## 'be'></syntaxhighlight> |
||
A syntactically correct declaration can be commented out like this. |
A syntactically correct declaration can be commented out like this. |
||
< |
<syntaxhighlight lang="ursala">foo = 1 |
||
## |
## |
||
Line 1,546: | Line 3,484: | ||
bar = 2 |
bar = 2 |
||
baz = 3</ |
baz = 3</syntaxhighlight> |
||
As far as the compiler is concerned, bar is not defined, but foo and baz are. |
As far as the compiler is concerned, bar is not defined, but foo and baz are. |
||
It wouldn't matter if bar took multiple lines. |
It wouldn't matter if bar took multiple lines. |
||
Line 1,554: | Line 3,492: | ||
to embed comments in executable files and libraries it generates without |
to embed comments in executable files and libraries it generates without |
||
affecting their semantics. |
affecting their semantics. |
||
< |
<syntaxhighlight lang="ursala">#comment -[ |
||
I document the source text but will also be embedded in |
I document the source text but will also be embedded in |
||
the output library or executable file.]- |
the output library or executable file.]- |
||
#comment gpl'3'</ |
#comment gpl'3'</syntaxhighlight> |
||
The latter comment puts the standard GPL license notification in the output file. |
The latter comment puts the standard GPL license notification in the output file. |
||
Line 1,565: | Line 3,503: | ||
A function f annotated with a crash dump wrapper expressed like this |
A function f annotated with a crash dump wrapper expressed like this |
||
during debugging |
during debugging |
||
<lang |
<syntaxhighlight lang="ursala">my_input_type%C f</syntaxhighlight> |
||
is equivalent to just f when changed to this in the production code. |
is equivalent to just f when changed to this in the production code. |
||
<lang |
<syntaxhighlight lang="ursala">my_input_type%Ck f</syntaxhighlight> |
||
=== Comments as hooks === |
=== Comments as hooks === |
||
Line 1,573: | Line 3,511: | ||
Compiling with the --depend command line option makes the compiler only scan for the #depend'ed |
Compiling with the --depend command line option makes the compiler only scan for the #depend'ed |
||
expressions and send them to standard output. |
expressions and send them to standard output. |
||
< |
<syntaxhighlight lang="ursala">#depend <this,expression> is (parsed)* but { |
||
otherwise, |
otherwise, |
||
ignored}</ |
ignored}</syntaxhighlight> |
||
This way, scripts and source management tools can have information passed to them from |
This way, scripts and source management tools can have information passed to them from |
||
the programmer by running the compiler instead of re-implementing their own parsers. |
the programmer by running the compiler instead of re-implementing their own parsers. |
||
=={{header|VBA}}== |
|||
A comment starts with a quote (') and it ends at end of line |
|||
<syntaxhighlight lang="vb">' This is a VBA comment |
|||
</syntaxhighlight> |
|||
=={{header|VBScript}}== |
|||
A comment starts with a quote (') and it ends at end of line |
|||
<syntaxhighlight lang="vb">' This is a VBScript comment |
|||
</syntaxhighlight> |
|||
=={{header|Verbexx}}== |
|||
<syntaxhighlight lang="verbexx"> |
|||
////////////////////////////////////////////////////////////////////////////////////////////// |
|||
// |
|||
// Line Comments: |
|||
// ============= |
|||
// |
|||
@VAR v1 = 10; // Line comments start from the "//" and continue to end of the line. |
|||
// (normal code can appear on the same line, before the //) |
|||
// |
|||
// Line comments can span a complete line, or start in the middle of a line. |
|||
/// |
|||
//// Additional // chars and /* /* /[ ]/ and /] are ignored |
|||
//// Line comments can be appear to be nested, since any additional // is ignored. |
|||
/// |
|||
// Note: // can appear in strings without triggering a line comment |
|||
// // cannot appear inside an operator (or verbname), since a line comment |
|||
// would start |
|||
// |
|||
///////////////////////////////////////////////////////////////////////////////////////////// |
|||
/******************************************************************************************** |
|||
* |
|||
* Block Comments: |
|||
* ============== |
|||
* |
|||
********************************************************************************************/ |
|||
//* |
|||
//* These start with /* and end with the next */ . They cannot be nested, since the first */ |
|||
//* will end the block comment. For example, the comment, /* /* */ */ would end after the |
|||
//* first */. Note that /* is ignored inside a block comment, as are // /[ /] and /]. |
|||
//* |
|||
//* Also note that something like the following will cause trouble in a block comment: |
|||
//* |
|||
//* /* comments // |
|||
//* * more comments // */ (the // does not prevent the */ from ending |
|||
//* * (no longer part of the comment) // block comment) |
|||
//* */ |
|||
//* |
|||
//* Note: /* can appear in strings without triggering the start of a block comment |
|||
//* /* cannot appear inside an operator (or verbname), since a line comment will |
|||
//* start, although */ is allowed inside an operator (verbname). Commenting |
|||
//* out such a verbname may cause problems. |
|||
//* |
|||
//* Note: Since string literals are not recognized in block comments, */ appearing |
|||
//* in a string literal inside a block comment (perhaps commented-out code) |
|||
//* will cause the block comment to end. |
|||
//* |
|||
//* Note: It is an error to start a block comment and not end it, so that it is still |
|||
//* in progresss when the end-of-file is reached. |
|||
//* |
|||
//* Block comments can appear inside lines of code: |
|||
//* |
|||
/*1*/@VAR/*2*/v2/*3*/=/*4*/20/*5*/;/*6*/ // a line comment can follow block comments on the |
|||
// same line |
|||
/[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][] |
|||
/[] [] |
|||
/[] Nestable Block Comments: [] |
|||
[] ======================== []/ |
|||
[] []/ |
|||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]/ |
|||
//[] |
|||
//[] These start with /[ and end with the next matching ]/ . Additional occurrences |
|||
//[] of /[ ... ]/ can appear inside a nestable block comment. The nestable block comment |
|||
//[] will end only when the nest level reaches 0. Note that /* is ignored inside a nestable |
|||
//[] block comment, as are */ // and /]. |
|||
//[] |
|||
//[] Nestable block comments can be used to comment out blocks of code containing line |
|||
//[] comments or regular comments, and even balanced and well-formed nestable block comments. |
|||
//[] |
|||
//[] Note: /[ can appear in strings without triggering the start of a block comment. |
|||
//[] However, strings literals are not recognized inside a nestable block comment, so |
|||
//[] any appearances of /[ and /] inside a string literal in a nestable block commment |
|||
//[] will affect the nest level, and may cause problems. |
|||
//[] |
|||
//[] Note: It is an error to start a nestable block comment and not end it, so that it is |
|||
//[] still in progresss when the end of file is reached. |
|||
//[] |
|||
//[] Nestable block comments can appear inside lines of code: |
|||
//[] |
|||
/[1]/@VAR/[2]/v3/[3]/=/[4]/30/[5]/;/[6]/ // a line comment can follow nestable block comments |
|||
// on the same line |
|||
@SAY v1 v2 v3; // should see: 10 20 30 |
|||
/] |
|||
/=================================================================================================\ |
|||
| | |
|||
| /] starts a block comment that lasts until the end of the current file. Everything after | |
|||
| the /] is ignored. | |
|||
| | |
|||
\=================================================================================================/ |
|||
</syntaxhighlight> |
|||
=={{header|Verilog}}== |
=={{header|Verilog}}== |
||
< |
<syntaxhighlight lang="verilog">// Single line commment. |
||
/* |
/* |
||
Line 1,586: | Line 3,630: | ||
line |
line |
||
comment. |
comment. |
||
*/</ |
*/</syntaxhighlight> |
||
=={{header|VHDL}}== |
=={{header|VHDL}}== |
||
< |
<syntaxhighlight lang="vhdl">-- Single line commment in VHDL</syntaxhighlight> |
||
=={{header|Vim Script}}== |
|||
All lines starting with " are comments and will be ignored. |
|||
In most cases, " will also work after a command (i.e. the rest of the line will be ignored). But some commands like <code>echo</code> treat the whole line as their argument and thus will raise an error (''Missing quote''). |
|||
<syntaxhighlight lang="vim">let a = 4 " A valid comment |
|||
echo "foo" " Not a comment but an argument that misses the closing quote</syntaxhighlight> |
|||
=={{header|Visual Basic}}== |
=={{header|Visual Basic}}== |
||
Line 1,595: | Line 3,647: | ||
In addition to the methods mentioned in [[#BASIC|BASIC]] above, it is also somewhat common to effectively comment out code by including the unwanted code inside an <code>#If 0 ... #End If</code> block. (This works because 0 evaluates to False in VB.) Note, however, that the IDE will complain about actual comments inside an <code>#If 0</code> block unless it's also commented normally (i.e., using <code>Rem</code> or <code>'</code>). |
In addition to the methods mentioned in [[#BASIC|BASIC]] above, it is also somewhat common to effectively comment out code by including the unwanted code inside an <code>#If 0 ... #End If</code> block. (This works because 0 evaluates to False in VB.) Note, however, that the IDE will complain about actual comments inside an <code>#If 0</code> block unless it's also commented normally (i.e., using <code>Rem</code> or <code>'</code>). |
||
< |
<syntaxhighlight lang="vb">'comment |
||
Rem comment |
Rem comment |
||
#If 0 |
#If 0 |
||
Line 1,601: | Line 3,653: | ||
IDE won't. Note the somewhat odd formatting seen here; the IDE will likely |
IDE won't. Note the somewhat odd formatting seen here; the IDE will likely |
||
just mark the entire line(s) as errors. |
just mark the entire line(s) as errors. |
||
#End If</ |
#End If</syntaxhighlight> |
||
=={{header|Visual Basic .NET}}== |
=={{header|Visual Basic .NET}}== |
||
Visual Basic .NET uses the "'" symbol or "REM" to mark it's comments. After placing a "'", or "REM", everything in that line will be ignored. |
Visual Basic .NET uses the "'" symbol or "REM" to mark it's comments. After placing a "'", or "REM", everything in that line will be ignored. |
||
< |
<syntaxhighlight lang="vbnet">' This is a comment |
||
REM This is also a comment |
REM This is also a comment |
||
Dim comment as string ' You can also append comments to statements |
Dim comment as string ' You can also append comments to statements |
||
Dim comment2 as string REM You can append comments to statements</ |
Dim comment2 as string REM You can append comments to statements</syntaxhighlight> |
||
=={{header|Visual Objects}}== |
|||
<syntaxhighlight lang="visualfoxpro"> |
|||
// This is a comment |
|||
/* This is a comment */ |
|||
* This is a comment |
|||
&& This is a comment |
|||
NOTE This is a commen |
|||
</syntaxhighlight> |
|||
=={{header|V (Vlang)}}== |
|||
<pre> |
|||
// This is a single line comment. |
|||
/* |
|||
This is a multiline comment. |
|||
/* It can be nested. */ |
|||
*/ |
|||
</pre> |
|||
=={{header|Vorpal}}== |
=={{header|Vorpal}}== |
||
<lang |
<syntaxhighlight lang="vorpal"># single line comment</syntaxhighlight> |
||
=={{header|Wart}}== |
|||
<syntaxhighlight lang="wart"># single-line comment</syntaxhighlight> |
|||
=={{header|Wren}}== |
|||
<syntaxhighlight lang="wren">// This is a line comment. |
|||
/* This is a single line block comment.*/ |
|||
/* This is |
|||
a multi-line |
|||
block comment.*/ |
|||
/* This is/* a nested */block comment.*/</syntaxhighlight> |
|||
=={{header|X10}}== |
|||
All text included within the ASCII characters “/*” and “*/” is considered a comment and ignored; nested comments are not allowed. |
|||
All text from the ASCII characters “//” to the end of line is considered a comment and is ignored. |
|||
<syntaxhighlight lang="x10">// This is a single line comment |
|||
/* |
|||
This comment spans |
|||
multiple lines |
|||
*/</syntaxhighlight> |
|||
=={{header|XLISP}}== |
|||
<syntaxhighlight lang="xlisp">; this is a comment</syntaxhighlight> |
|||
=={{header|Xojo}}== |
|||
<syntaxhighlight lang="vb"> |
|||
// Comments are denoted by a preceding double slash or or single quote |
|||
' and continue to the end of the line. There are no multi-line comment blocks |
|||
Dim foo As Integer // Comments can also occupy the ends of code lines</syntaxhighlight> |
|||
=={{header|XPL0}}== |
|||
Comments are enclosed in backslash characters, but the end of a line |
|||
always terminates a comment. Consequently there is no multi-line |
|||
comment. For example: |
|||
<syntaxhighlight lang="xpl0">Text(0, \comment\ "Hello \not a comment\ World!"); \comment</syntaxhighlight> |
|||
Since backslashes toggle comments on and off, it could be inconvenient to |
|||
comment out a line of code that contains a comment. For example, two |
|||
additional backslashes could be used to comment out this line, as shown here: |
|||
<syntaxhighlight lang="xpl0"> Text(0, "Hello World"); \comment |
|||
\Text(0, "Hello World"); \\comment</syntaxhighlight> |
|||
However, two backslashes together comment out everything to the end of |
|||
the line regardless of any backslashes the line might contain. So the |
|||
first example could be commented out like this: |
|||
<syntaxhighlight lang="xpl0">\\Text(0, \comment\ "Hello \not a comment\ World"); \comment</syntaxhighlight> |
|||
Conditional compilation can be used to effectively comment out multiple |
|||
lines of code. For example: |
|||
<syntaxhighlight lang="xpl0">cond false; |
|||
Text(0, "Hello World"); \comment |
|||
CrLf(0); |
|||
cond true;</syntaxhighlight> |
|||
=={{header|XQuery}}== |
=={{header|XQuery}}== |
||
< |
<syntaxhighlight lang="xquery">(: This is a XQuery comment :)</syntaxhighlight> |
||
=={{header|XSLT}}== |
=={{header|XSLT}}== |
||
< |
<syntaxhighlight lang="xml"><!-- Comment syntax is borrowed from XML and HTML. --></syntaxhighlight> |
||
=={{header|XUL}}== |
|||
[[Category:Initialization]] |
|||
<syntaxhighlight lang="xul"><!-- Comment syntax is borrowed from XML and HTML. --></syntaxhighlight> |
|||
=={{header|Yacas}}== |
|||
Yacas supports C++ style comments: |
|||
<syntaxhighlight lang="yacas">// This is a single line comment |
|||
/* |
|||
This comment spans |
|||
multiple lines |
|||
*/</syntaxhighlight> |
|||
=={{header|Z80 Assembly}}== |
|||
Note: syntax depends on the assembler software but use of a semicolon is fairly standard. VASM and WinAPE use the semicolon. |
|||
<syntaxhighlight lang="z80"> ld hl,&8000 ;This is a comment</syntaxhighlight> |
|||
=={{header|Zig}}== |
|||
<syntaxhighlight lang="zig">// This is a normal comment in Zig |
|||
/// This is a documentation comment in Zig (for the following line)</syntaxhighlight> |
|||
=={{header|zkl}}== |
|||
<syntaxhighlight lang="zkl">x=1; // comment ala C++ |
|||
x=2; # ala scripts |
|||
/* ala C, these comments are parsed (also ala C) */ |
|||
/* can /* be */ nested */ |
|||
#if 0 |
|||
also ala C (and parsed) |
|||
#endif |
|||
#<<<# |
|||
"here" comment, unparsed |
|||
#<<<#</syntaxhighlight> |
|||
=={{header|Zoea}}== |
|||
<syntaxhighlight lang="zoea"> |
|||
program comments # this program does nothing |
|||
# zoea supports single line comments starting with a '#' char |
|||
/* |
|||
zoea also supports |
|||
multi line |
|||
comments |
|||
*/ |
|||
</syntaxhighlight> |
|||
=={{header|Zoea Visual}}== |
|||
[http://zoea.co.uk/examples/zv-rc/Comments.png Comments] |
|||
=={{header|zonnon}}== |
|||
<syntaxhighlight lang="zonnon"> |
|||
(* this is a comment *) |
|||
(* |
|||
and this is a |
|||
multiline comment |
|||
(* with a nested comment *) |
|||
*) |
|||
</syntaxhighlight> |
|||
=={{omit from|Computer/zero Assembly}}== |
Latest revision as of 13:12, 24 July 2024
You are encouraged to solve this task according to the task description, using any language you may know.
- Task
Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter.
- Related tasks
- See also
11l
// Single line comment \\ Also single line comment (continuation of the comment in previous line) \[ This is a multi line comment ] \{ And this } \( And this ) \‘ And this ’
360 Assembly
* An asterisk in column one denotes a comment line
* Comments may also follow any syntactically complete instruction:
LA 1,0 Comment
NOP Comment (after a NOP instruction)
* Comments after instructions with omitted operands require a comma ","
END , Comment (without comma, "Comment" assumed an operand of "END")
4D
`Comments in 4th Dimension begin with the accent character and extend to the end of the line (until 4D version 2004).
// This is a comment starting from 4D v11 and newer. Accent character is replaced by //
4ME
P:This is a comment out{hi!} This i also a comment # This is a Python-Like comment E: Anything after the "E:" command wont be executed
6502 Assembly
Note: syntax depends on the assembler software but use of a semicolon is fairly standard
nop ; comments begin with a semicolon
68000 Assembly
Note: syntax depends on the assembler software but use of a semicolon is fairly standard
EASy68k uses * as the comment character. VASM uses a semicolon ;
MOVEM.L D0-D7/A0-A6,-(SP) ;push all registers onto the stack
8086 Assembly
Note: syntax depends on the assembler software but use of a semicolon is fairly standard
MOV AX, 4C00h ; go back to DOS
INT 21h ; BIOS interrupt 21 base 16
AArch64 Assembly
/* ARM assembly AARCH64 Raspberry PI 3B */
/* comments multi lines
end comments
*/
// comment end of ligne
ACL2
Just like Common Lisp:
; Single line comment
#| Multi-line
comment |#
Action!
Action! supports only single line comments which begin with semicolon.
;This is a comment
PROC Main() ;This is a comment as well
RETURN
- Output:
Screenshot from Atari 8-bit computer
ActionScript
- See Java
Ada
-- All Ada comments begin with "--" and extend to the end of the line
Agena
Agena has single line comments and two styles of multi-line comments.
# single line comment
#/ multi-line comment
- ends with the "/ followed by #" terminator on the next line
/#
/* multi-line comment - C-style
- ends with the "* followed by /" terminator on the next line
*/
ALGOL 60
A comment in ALGOL 60 takes the place of a single instruction.
'COMMENT' this is a first comment;
'COMMENT'
****** this is a second comment ******
;
ALGOL 68
With Standard
Comments can be inserted in variety of ways:
Algol68 as typically published,
includes bold typeface. |
Quote stropping,
like to Wiki markup. |
Case stropping,
7-bit/ascii implementations. |
Res stropping,
detecting reserved words. |
Point stropping,
6-bits/byte implementations. |
¢ The original way of adding your 2 cents worth to a program with the "cent" character ¢ | ¢ TEXT ¢ | |||
co Style i comment co
comment text comment |
'co' text 'co'
'comment' text 'comment' |
CO text CO
COMMENT text COMMENT |
co text co
comment text comment |
.CO TEXT .CO
.COMMENT TEXT .COMMENT |
# Style ii comment with the hash character # | # TEXT # |
Notes:
- The # test # and ¢ text ¢ comment tends to be used for inline comments. And the COMMENT text COMMENT style tends to be used to comment out entire blocks.
- The script algol68.vim can be used to highlight commented blocks while editing source code.
With Extensions
£ This is a hash/pound comment for a UK keyboard £
ALGOL-M
begin
comment - This form is borrowed from ALGOL 60;
% And this is borrowed from ALGOL W %
% ALGOL-M will not compile an "empty" program, so we have %
% to include at least one code-generating statement! %
write("This is only an exercise");
end
ALGOL W
Comments in Algol W can appear anywhere whitespace is allowed. A comment starts with the reserved word 'comment' and ends with the next semi-colon. Alternatively a comment can start with a percent sign and end with the next percent sign or semi-colon.
A single word in the form of an identifier following the reserved word 'end' is also a comment.
begin
comment a comment;
% another comment
;
% and
another
%
end this_word_is_also_a_comment.
AmigaE
/* multiline comment
are like C ... */
-> this is a end of line comment
AngelScript
// This is a comment
AntLang
2 + 2 /This is a comment
Apex
System.debug ('I will execute'); // This comment is ignored.
/*
I am a large comment, completely ignored as well.
*/
APL
⍝ This is a comment
AppleScript
--This is a single line comment
display dialog "ok" --it can go at the end of a line
# Hash style comments are also supported
(* This is a multi
line comment*)
(* This is a comment. --comments can be nested
(* Nested block comment *)
*)
display dialog "ok" #Starting in version 2.0, end-line comments can begin with a hash
Arendelle
Arendelle uses C style comments
ARM Assembly
/* ARM assembly Raspberry PI comment one line */
/* comment line 1
comment line 2
*/
mov r0,#0 @ this comment on end of line
mov r1,#0 // authorized comment
Arturo
; This is a simple single-line comment
a: 10 ; another single-line comment
; Now, this is a
; multi-line comment
Asymptote
// double slash to newline
See programming introduction in the Asymptote manual.
When reading data files a comment character in them can be specified as comment="#"
etc. See Files in the Asymptote manual.
AutoHotkey
Msgbox, comments demo ; end of line comment
/*
multiline comment1
multiline comment2
*/
For multi-line comments, the /* and */ must be on their own separate lines. Nothing else can be on the same line.
AutoIt
#cs
Everything between the cs and and the ce is commented.
Commented code is not used by the computer.
#ce
;individual lines after a semicolon are commented.
AWK
The hash symbol # start a comment; it ends at the end of line.
BEGIN { # this code does something
# do something
}
Axe
.This is a single-line comment
...
This is a multi-line comment
...
...If 0
This is a comment only if the condition evaluates to zero
...
...!If 1
This is a comment only if the condition evaluates to nonzero
...
...Else
This is a comment only if the previous conditional comment was executed (and vice versa)
...
Babel
-- This is a line-comment
#
This is a block-comment
It goes until de-dent
dedent: 0x42 -- The comment block above is now closed
BASIC
The only truly standard method of marking a comment in BASIC is using the REM
keyword. This dates back to (at least) the late 1970's, and should work with most BASICs available today:
100 REM Standard BASIC comments begin with "REM" (remark) and extend to the end of the line
110 PRINT "this is code": REM comment after statement
This may not be well known, but you may include text after the line number of GOTO and GOSUB statements. This is kind of a comment in absence of labels.
100 GOTO 200HERE 110 GOSUB 300THERE 120 GOTO 400THEOTHERPLACE 130 GOTO 500MOM AND POP
Spaces are removed from non-keyword text. BASIC keywords can be used. List outputs spaces around keywords.
Most BASICs also support alternate comment characters, commonly an apostrophe (single quote):
'this is a comment
PRINT "this is code" 'comment after statement
Characters other than apostrophe are used in some BASICs. For example, DarkBASIC uses a back-tick character (`, a.k.a. grave accent):
`this is a comment PRINT "this is code" `comment after statement 'this is NOT a comment!
In addition to single-line comments, a few BASICs support block comments. FreeBASIC was influenced by the C family's block comment characters:
/' This is a multi line comment. Requires FreeBASIC 0.16 or later. Last line of the comment block. '/ DIM a AS /' Comment in the middle of statement '/ Integer
Applesoft BASIC
Comment by making a REMark using the REM keyword
REM COMMENT AFTER THE REM KEYWORD
When LISTing the program a space is added after the REM keyword
0 REMLEAVE THE SPACE OUT AFTER THE REM WHEN TYPING OR PASTING
The remark extends until the end of the line. Only the first THIS IS CODE is printed.
10 PRINT "THIS IS CODE" : REM : PRINT "THIS IS CODE"
A comment can come after a GOSUB and when the subroutine returns it continues running the statements after the GOSUB comment.
20 GOSUB 110COMMENT: PRINT "THIS IS CODE"
Anything after a GOTO or RETURN statement is ignored.
30 GOTO 40"COMMENT: THIS IS A COMMENT
There are other ways to add spacing and comments to code.
::::::::::::::::::::::::::::::::::::::
40 REM
50 :
60 REM<ctrl>+J
70 FOR I = 1 to 10
80 ::::PRINT I;MID$("THIS IS A COMMENT",1,0)
90 NEXT
Typing CONTinue after the program ENDs will result in a ?SYNTAX ERROR.
100 END : THISISACOMMENT
Use the quotation symbol " before the comment so that spaces are included and keywords are ignored.
110 RETURN : "COMMENT FOR AND AT THE END
BaCon
BaCon accepts REM (or single quote apostrophe) for line comments.
C-style block comments can be used with /* and */ pairs; these comment blocks may cross line boundaries.
Inside USEC sections, all comment styles accepted by the configured C compiler will also be ignored.
BASIC256
rem this is a comment
# and this is too
print "this is code" #comment after statement
Chipmunk Basic
10 rem this is a comment
20 ' and this is too
30 print "this is code" : 'comment after statement
40 print "and more code" : rem comment after statement
IS-BASIC
100 REM Standard BASIC comments begin with "REM" (remark) and extend to the end of the line
110 PRINT "this is code" ! comment after statement
Minimal BASIC
10 REM STANDARD BASIC COMMENTS BEGIN WITH "REM" AND EXTEND TO THE END OF LINE
20 END
MSX Basic
10 rem this is a comment
20 ' and this is too
30 print "this is code" : '[:] it's optional
40 print "and more code" : rem comment after statement
Quite BASIC
10 rem this is a comment
20 print "this is code" : rem comment after statement
True BASIC
!this is a comment
PRINT "this is code" !comment after statement
XBasic
PROGRAM "Comments"
VERSION "0.0000"
DECLARE FUNCTION Entry ()
FUNCTION Entry ()
'this is a comment
PRINT "this is code" 'comment after statement
END FUNCTION
END PROGRAM
Yabasic
rem Hey, this is a comment
# the hash-sign too (at beginning of line)
// even the double slash
' and the single quote (at beginning of line)
print "Not a comment" # This is an error !!
print "Not a comment":// But this is again a valid comment
print "Not a comment" // even this.
print "Not a comment" rem and this !
Batch File
rem Single-line comment.
There is another (undocumented) option, using a double-colon ::
. However, this has issues with some syntactic constructs and therefore may raise syntax errors.
:: Another option, though undocumented and known
:: to fail in some cases. Best avoided.
Yet another (undocumented) option, using (not delayed) variable expansion as long as it is undefined. This works because undefined variables result to blank line when expanded using %
.
% this works as long as you have no variable named exactly like this sentence. %
Since comment lines are skipped entirely by the parser, multi-line comments aren't possible even with line continuation.
BBC BASIC
REM This is a comment which is ignored by the compiler
*| This is a comment which is compiled but ignored at run time
bc
/* This is a comment. */
2 + /* Comment between tokens. */ 3
"This is a string, /* NOT a comment */."
/*
* A comment can have multiple lines. These asterisks in the middle
* of the comment are only for style. You must not nest a comment
* inside another comment; the first asterisk-slash ends the comment.
*/
#!/usr/bin/bc
# This form of comment is an extension, not part of standard bc.
# Your program must not have a #! shebang line
# unless your bc supports this form of comment.
2 + 3 # It can be after a statement.
a = 1 # The newline is not part of the comment.
b = 2 # So this line is a different statement.
Beef
//This is a comment.
//This is another comment.
/* This is also a comment. */
/* This is a
multi-line
comment */
The IDE allows for documenting types and methods with /// or /** */ (which one of these you use doesn’t matter). Autocomplete suggestions, as well as prompts while calling/using the documented types or functions, will display their documentation.
static
{
/// Must be placed directly above the method, including attributes.
/// Using multiple lines like this is also fine. Both will be recognized.
[Optimize]
public static void DoAThing() {}
/// Documentation also works for types.
struct SomeStruct
{
/**
* Multiline comment with two ** at the start works in the same way.
*/
void PrivateMethod() {}
}
/**
* If you have a really long explainer here, you may not actually want to show that in autcompletion prompts.
* @brief Allows you to select only this line to be shown.
*
* @param a This is shown when writing a call to this function and placing parameter "a".
* @param b For the second argument, the documentation for b (this!) will show up instead.
*/
public static void DoAnotherThing(int a, int b) {}
}
Befunge
Like Brainf***, all characters and whitespace which are not commands are ignored. Also, since the code/data-space is two-dimensional, comments can be placed anywhere that will be untouched by the instruction pointer and data access commands. Finally, in Funge-98, the ; instruction immediately skips to the next ; instruction, which allows to isolate comments from code.
& read a number 2+ add two .@ display result and exit
^- inline comments -^ <-^- other comments
&;read a number;2+;add two;.@;display result and exit;
^- inline comments -^ <-^- other comments
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;completely isolated comment block for the paranoid;
;(almost - you can still skip into it.) ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Binary Lambda Calculus
BLC has no notion of comments, but since input is considered part of the program, one can always ignore the remainder of input, which can thus be arbitrary. Of course one can have comments in any language that translates to BLC, as discussed in https://rosettacode.org/wiki/Documentation#Binary_Lambda_Calculus
Blast
# A hash symbol at the beginning of a line marks the line as a comment
BQN
# This is a comment
Bracmat
Bracmat uses curly braces as comment delimiters. Curly braces inside comments must be balanced. Comments are so much ignored when source code is read, that they do not reappear in listings created by the built-in lst$
function, an otherwise very useful function to autoindent your code.
Brainf***
This is a comment
Most ASCII characters may be used for comments; only the eight characters "+-<>[],." are Brainf*** commands. Extra care must be used when using punctuation, particularly the comma or period. These are I/O operators and are actually commands rather than comments, and are instead compiled into the program if used and may have to be "debugged" and removed if you forget this issue. Another workaround for this issue is to tactically place the comment inside a "[]" loop which can never be entered (The loop will only be encountered when the active memory cell value is 0).
Brat
# Single line comment
#* Multi
Line
Comment *#
Bruijn
Bruijn does not have multi-line comments.
# This is a comment
Brlcad
# Comments in mget scripts are prefixed with a hash symbol
ls # comments may appear at the end of a line
Burlesque
Burlesque does NOT have comments. However, you can comment code by pushing a string and popping it immediately.
"I'm sort of a comment"vv
Since strings are multi-line strings:
"I'm a
very long comment spanning
over several lines"vv
C
/* This is a comment. */
/* So is this
multiline comment.
*/
The comment starts at the /*, and ends at the */. A comment may be used between any tokens. It cannot be used inside tokens, that is, given the code
struct charisma {};
void f(char/* comment */isma) {}
the function takes an argument of type char, named isma, not an unnamed argument of type charisma.
Comments cannot be nested; that is, if you write
/* some comment /* trying to nest some other comment */ inside */
the comment ends at the first */, and inside */ is again interpreted as source code (almost certainly causing a compile error). Some compilers have the option to allow nested comments, but this is not a standard feature.
Conditional compilation also can be used to make the compiler ignore some text:
#if 0
While technically not a comment, this is also ignored by the compiler
#endif
The trick is that 0 is always false, therefore the text between #if 0 and #endif is never compiled. While this should never be used for actual comments, it's an easy way to comment out some code, especially because it doesn't interfere with normal (documentation) comments.
Conditional compile "comments" can be nested:
#ifdef UNDEFINED
This is not compiled.
#if 0
Nor is this.
#endif
And this still is not compiled.
#endif
Even though the compiler doesn't see #if 0 text, the preprocessor does. Therefore some minimal rules still have to be followed. For example, the following code is not valid:
#if 0
This isn't valid.
#endif
That's because the preprocessor will interpret the apostrophe as beginning of a character constant, and will complain because that character constant isn't terminated with another apostrophe.
Note that the problem mentioned above cannot occur if there's valid code between the #if 0 and #endif.
// C++ single-line comments were adopted in the C99 standard.
C#
//This is a comment.
//This is other comment.
/* This is a comment too. */
/* This is a
multi-line
comment */
C++
- See also C
Single line C++-style comments
// This is a comment
C++-style comments start with // and reach up to, but not including, the end of line (more exactly, up to the next unescaped newline). While formally, C++-style comments cannot be nested either, in practice they can:
// This is a valid comment // with a "nested" comment
That's because starting with the first // everything in the line is ignored, including the second //. The fact that the newline is not part of the comment is important for multi-line macro definitions. It means that in the code
#define FOO \
(macro text) // comment
(no more macro text)
the line (no more macro text) is not part of the macro definition. Also escaping the line break at the end of the comment with '\' doesn't help, because that would make the third line part of the comment instead. Comments inside macros therefore have to be C-style.
Chapel
// single line
/* multi
line */
Chef
Comment Stew.
This is a comment.
The other comment is a loop, but you can name it anything (single word only).
You can also name ingredients as comments
This is pseudocode.
Ingredients.
Ingredient list
Method.
Methods.
SingleWordCommentOne the Ingredient.
Methods.
SingleWordCommentTwo until SingleWordCommentOned.
Methods.
ChucK
<-- Not common
// Usual comment
Clean
Clean comments are similar to C++.
Start = /* This is a multi-
line comment */ 17 // This is a single-line comment
In contrast to C++ comments can be nested.
Start = /* This is a comment /* Nested comment */ still a comment */ 17
Clojure
Anything from a semicolon to the end of a line is a comment.
;; This is a comment
(defn foo []
123) ; also a comment
The (comment)
macro will prevent a form from being evaluated, returning nil
no matter what is contained in the comment. However the forms inside the comment
form must be properly parseable (parentheses balanced, etc.) or an exception will be thrown.
(comment (println (foo)) "bar" :baz 123 (System/exit 0)) ;; does nothing, returns nil
Finally, the #_
reader macro will cause a form to be ignored by the reader. Unlike (comment)
, this does not return nil
; the surrounding code is evaluated as though the ignored form isn't even there.
(+ 1 (comment "foo") 3) ;; Throws an exception, because it tries to add nil to an integer
(+ 1 #_"foo" 3) ;; Returns 4
CMake
Line comments use the common #
syntax:
# A single-line comment
Multi-line comments use a Lua-like square-bracket syntax.
#[[A multi-line
comment ]]
#[==[A multi-line comment
with [[nested brackets]]. ]==]
The number of equals signs (=
) in the opening bracket determines the number expected in the closing bracket.
COBOL
Fixed format
* an asterisk in 7th column comments the line out
A D in the 7th column indicates a debugging line which is treated like a comment unless a compiler flag is set.
D DISPLAY "Debug"
Free format
*> This comment syntax was defined (with free format code) in COBOL 2002.
This indicates a debugging line like above, but if it is used in fixed format files, it must be in the 8th column or beyond. Not necessarily. GnuCOBOL also supports D as an indicator in column 7, the >>D format works (more by trickery than spec) if the angle brackets start in column 5, the D ending up in column 7. The >>D debug marker can then be both fixed and free form compatible.
>>D DISPLAY "Debug"
NOTE
statement
This statement causes everything following it up to the next separator period to be treated as a comment. This statement was deleted in COBOL-74.
NOTE this paragraph is
commented out and ignored
.
REMARKS
and other statements
There are quite a few IDENTIFICATION DIVISION
obsolete and extension reserved words that will work in GnuCOBOL 2.
IDENTIFICATION DIVISION.
PROGRAM-ID. program.
AUTHOR. Rest of line ignored.
REMARKS. Rest of line ignored.
REMARKS. More remarks.
SECURITY. line ignored.
INSTALLATION. line ignored.
DATE-WRITTEN. same, human readable dates are allowed for instance
DATE-COMPILED. same.
DATE-MODIFIED. this one is handy when auto-stamped by an editor.
Those lines can occur multiple times each within the IDENTIFICATION DIVISION. There can be many AUTHORs, SECURITY notes, etc. These words are also supported by other COBOL dialects, but may have different rules on order, multiples allowed of if full stop periods are required (or allowed) before the end of line.
CoffeeScript
# one line comment
### multi
line
comment ###
ColdFusion
In tags:
As ColdFusion's grammar is based around HTML syntax, commenting is similar to HTML.
<!--- This is a comment. Nothing in this tag can be seen by the end user.
Note the three-or-greater dashes to open and close the tag. --->
<!-- This is an HTML comment. Any HTML between the opening and closing of the tag will be ignored, but any ColdFusion code will still run.
Note that in the popular FuseBox framework for ColdFusion, the circuit.xml files require that you use this style of comment. -->
In script:
/* This is a comment */
// This is also a comment
Common Lisp
Common Lisp provides line comments (;) and block comments (#|...|#).
Block comments can nest (#|...#|...|#...|#), unlike block comments in e.g. C.
In a common convention, header comments are prefaced with four semicolons, top-level (function level) comments use three, comments for sections of code use two, and margin comments use one.
;;;; This code implements the foo and bar functions
;;; The foo function calls bar on the first argument and multiplies the result by the second.
;;; The arguments are two integers
(defun foo (a b)
;; Call bar and multiply
(* (bar a) ; Calling bar
b))
;;; The bar function simply adds 3 to the argument
(defun bar (n)
(+ n 3))
However, comments should not be used for inline documentation, as most defining constructs permit a documentation string (which is then available at runtime).
(defun bar (n)
"Add 3 to the argument."
(+ n 3))
(defclass button (widget)
(label action)
(:documentation "This is a push-button widget."))
Component Pascal
(* Comments (* can nest *)
and they can span multiple lines.
*)
Crystal
# currently, Crystal only supports single-line comments
# This is a doc comment. Any line *directly* above (no blank lines) a module, class, or method is considered a doc comment
# Doc comments are used to generate documentation with `crystal docs`
class Foo
end
D
void main() {
// A single line comment.
/* This is a simple C-style comment that can't be nested.
Comments mostly work similar to C, newlines are irrelevant.
*/
/+ This is a nestable comment
/+ See?
+/
+/
/// Documentation single line comment.
/**
Simple C-style documentation comment.
*/
/++
Nestable documenttion comment.
+/
}
Dart
// This is a single line comment, which lasts until the end of the line. The Dart linter prefers this one.
/* This is also a valid single line comment. Unlike the first one, this one terminates after one of these -> */
/*
You can use the syntax above to make multi line comments as well.
Like this!
*/
/// These are doc comments. You can use dartdoc to generate doc pages for your classes with these.
///
/// Formatting [variable] and [function] names like so allows dartdoc to link to the documentation for those entities.
dc
There is no comment syntax in POSIX dc. The convention is to make a string on the stack and move it to an unused register; a no-op.
[Making and discarding a string acts like a comment] sz
GNU dc added the comment syntax of many other scripting languages.
# remainder of line is a comment
Delphi
- See also Pascal
In addition to Pascal, Delphi also allows C++ style single line comments:
// single line comment
Deluge
Comments are only allowed in places such as "on load" scripts. You cannot put them in form or view definitions.
// single line comment
Dragon
// This is a comment
/*
This is
a multiple
line comment.
*/
showln "Hello " /* This is an inline comment */ "world"
DWScript
(* This is a comment.
It may extend across multiple lines. *)
{ Alternatively curly braces
can be used. }
/* C-style multi-line comments
are supported */
// and single-line C++ style comments too
Dyalect
/* This is a
multi-line comment */
//This is a single-line comment
Dylan
// This is a comment
/*
This is a comment
that spans multiple
lines
*/
Déjà Vu
#this is a comment
!print "this is not a comment, obviously" #this is a comment as well
E
# This is a regular comment.
? "This is an Updoc comment, which
> is an executable example or test case.".split(" ")
# value: ["This", "is", "an", "Updoc", "comment,", "which
# is", "an", "executable", "example", "or", "test", "case."]
All comments span to the end of the line; there are no paired-delimiter comment syntaxes. “#
” begins a comment anywhere outside of quotes; “?
” and “>
” begin comments only if they are at the beginning of a line (except for whitespace), because those characters are also used for infix operators.
In Updoc, “?
” indicates the beginning of a program fragment, “>
” the continuation of one, and “#
” begins the expected output from its evaluation; “??
” indicates special directives.
EasyLang
# This is a comment
EchoLisp
666 ; this is an end-of-line comment
#|
This is a multi-line comment
Nesting is not allowed
|#
;; The (info <name> [<string>)] function associates a symbol and a comment
;; These info strings are saved in permanent memory (local storage)
;; Unicode characters may be used, as everywhere in the language
(define mynumber 666) → mynumber
(info 'mynumber "👀 Symbols may be commented with an information string 👺")
(info 'mynumber) → displays the above inside the 'info' field.
ECL
Single-line comments must begin with //
// this is a one-line comment
Block comments must be delimited with /* and */
/* this is a block comment - the terminator can be on the same line
or any succeeding line – everything in between is ignored */
Ecstasy
Comments in Ecstasy follow the two forms used by most C-family languages:
/*
* This is a multi-line comment.
*/
Int i = 0; // This is an end-of-line comment
ed
# A single-line comment.
# The only type of comment, really.
# No block comments in ed
EDSAC order code
EDSAC programs were handwritten on "programme sheets" designed for the purpose. The programmer, or a computer operator, then copied the "orders" (instructions) to punched tape for input to the machine. Programme sheets had a column for "notes" (comments), but these were not copied to the tape. Modern simulators, however, accept square brackets as comment delimiters.
[This is a comment]
[
And so
is
this
]
[But in 1949 they wouldn't have been]
EGL
- See Java
Eiffel
-- inline comment, continues until new line
Ela
//single line comment
/*multiple line
comment*/
Elena
//single line comment
/*multiple line
comment*/
Elixir
Elixir does not have multiple line comments.
# single line comment
Elm
-- a single line comment
{- a multiline comment
{- can be nested -}
-}
Emacs Lisp
A comment is started by ;
and reaches to the end of the line.
; This is a comment
There are some coding conventions for ;;
align to indentation, ;;;
sections, etc,
Another way to add comments is to use strings at places where the result of an expression is ignored, since they simply evaluate to themselves without any effect. Note that strings can be multi-line:
"This is effectively a comment,
if used at a place where the result is ignored"
Note that strings at the beginning of function definitions are interpreted as documentation strings for the function (i.e. Emacs will display them if asked for help about the function), e.g.
(defun subtract-second-from-first (x y)
"This function subtracts its second argument from its first argument."
(- y x))
Due to this, it's debatable if the string at that place can be considered as comment.
EMal
# This is a line comment.
^|This is a single line block comment.|^
^| This is
| a multi-line
| block comment.
|^
^|This is a ^|nested|^ block comment.|^
Erlang
% Erlang comments begin with "%" and extend to the end of the line.
ERRE
! Standard ERRE comments begin with ! and extend to the end of the line
PRINT("this is code") ! comment after statement
Euphoria
Single line comment:
-- This is a comment
Multiline C-style comment:
/*
This is a comment
*/
F#
F# accepts C++ type line comments and OCaml type block comments
// this comments to the end of the line
(* this comments a region
which can be multi-line *)
Factor
! Comments starts with "! "
#! Or with "#! "
! and last until the end of the line
USE: multiline
/* The multiline vocabulary implements
C-like multiline comments. */
Falcon
Falcon supports C-language style single line and block comments. A single line comment begins with two slashes (//) and ends at the end of the line. A block comment begins with a slash followed by an asterisk, and terminates when an asterisk followed by a slash is met (/*...*/).
/* Start comment block
My Life Story
*/
// set up my bank account total
bank_account_total = 1000000 // Wish this was the case
FALSE
{comments are in curly braces}
Fancy
# Comments starts with "#"
# and last until the end of the line
Fennel
; This is a single-line comment
Fermat
Function Foo(n) =
{Comments within a function are enclosed within curly brackets.}
{You can make multi-line comments
such as this one.}
n:=n^2 + 3n - 222; {Comments can go after a semicolon.}
n:=n+1;
n.
; comments between functions are preceded by semicolons, like this
Function Bar(n) =
2n-1.
Fish
Since ><> is a funge-like language, all characters not touched by the command pointer or modified by the p and g commands can be comments. Unlike Brainf***, unknown commands are not ignored by the compiler, they just raise an error.
v This is the Fish version of the Integer sequence task
>0>:n1+v all comments here
^o" "< still here
And of course here :)
Forth
Standard Forth includes a number of ways to add comment text. As with everything in Forth, comment characters are actually words that control the compiler.
\ The backslash skips everything else on the line
( The left paren skips everything up to the next right paren on the same line)
Traditionally, the paren comments are used for "stack effect" notation:
: myword ( a b -- c ) ...
This comment means "myword takes two cells on the stack and leaves one". Sometimes, stack effect comment names give clues about the word's function:
: add'em ( a b -- a+b ) + ;
: strlen ( addr -- len ) count nip ;
Some Forth systems implement other commenting words, such as these words from Win32Forth:
\s skips all remaining text in the file
(( skips until the next double-paren,
stretching across multiple lines ))
comment:
Ignore all text in this section
comment;
doc
Another comment block
enddoc
/* C-style comment */
(* Pascal-style comment *)
Fortran
Compiler: ANSI FORTRAN 77 or compatible (like g77 -strict)
The first six columns in Fortran are traditionally reserved for labels and certain special characters. In particular the letter "C" in the first column indicates a comment:
C This would be some kind of comment
C Usually one would avoid columns 2-6 even in a comment.
Some Fortran compilers have the extension that comments starting with D are treated as non-comments if a special debugging flag is given at the compiler invocation. For example:
C If compiled in debugging mode, print the current value of I
D PRINT *, I
ISO Fortran 90 or later have an inline comment (!) syntax:
real :: a = 0.0 ! initialize A to be zero
In ISO Fortran 90 or later, "C in first column" comments are only allowed in the "fixed" source form familiar to FORTRAN 77 programmers. The "free" source form only has inline comments (!).
ISO Fortran 95 or later has an optional conditional compilation syntax. If present, it can be used (abused?) to (in effect) comment out blocks of code:
?? if (.false.) then
do while (oh_no)
a = bad_news()
b = big_mistake()
c = gigo()
end do
?? end if
FreeBASIC
' FB 1.05.0 Win64
' This a single line comment
REM This is another way of writing a single line comment
/'
This is a
multi-line
comment
'/
/'
Multi-line comments
/'
can also be nested
'/
like this
'/
Frink
// This is a single-line comment
/* This is a comment
that spans multiple lines
and so on.
*/
Futhark
-- Single-line comment
-- Multi-line
-- comment (yes, just several single-line comments).
FutureBasic
// Single line comment
rem Single line comment
/* Single line comment */
/*
Multiline
comment
*/
FUZE BASIC
//Comment (No space required)
# Comment (Space required)
REM Comment (Space require)
PRINT "This is an inline comment."//Comment (No space required)
END
Gambas
In gambas, comments can be inserted by prefixing them with an apostrophe. The gambas interpreter will ignore the apostrophe and any other characters that follow it until the end of the line:
' This whole line is a comment and is ignored by the gambas interpreter
print "Hello" ' Comments after an apostrophe are ignored
'' A bold-style comment
' TODO: To Do comment will appear in Task Bar
' FIXME: Fix Me comment will appear in Task Bar
' NOTE: Note commnet will appear in Task Bar
GAP
# Comment (till end of line)
gecho
( this is a test comment... o.O ) 1 2 + .
Gema
! comment starts with "!" and continues to end of line
A shebang (#!) may be used as a comment in the first line of a file.
Genie
Genie allows comments in code in two different ways.
// Comment continues until end of line
/* Comment lasts between delimiters */
Delimited comments cannot be nested.
GML
single-line comment:
// comment starts with "//" and continues to the end of the line
multi-line comment:
/* a multi-line comment starts with slash-asterisk and,
ends with asterisk-slash.
also note:
* A multi-line comment is ignored inside a string
* A multi-line comment can be ended inside a line
*/
gnuplot
# this is a comment
# backslash continues \
a comment to the next \
line or lines
The way backslash continues a comment means that comments can't usefully be put within a multi-line function definition,
# this doesn't work
foo(n) = (n \
+ 2 # no good \
+ 3)
# behaves as if you wrote merely
foo(n) = (n+2
Go
// this is a single line comment
/* this is
a multi-line
block comment.
/* It does not nest */
Golfscript
# end of line comment
Gri
#
through to newline.
# this is a comment
show 123 # this too is a comment
//
works similarly but is reckoned the "old way" (as of Gri 2.12.23)
// this is a comment
show 123 // this too is a comment
Both forms can be used in input data files too.
Groovy
- See Java
GW-BASIC
100 REM Standard BASIC comments begin with "REM" (remark) and extend to the end of the line
110 PRINT "this is code": REM comment after statement
Haskell
i code = True -- I am a comment.
{- I am also
a comment. {-comments can be nested-}
let u x = x x (this code not compiled)
Are you? -}
-- |This is a Haddock documentation comment for the following code
i code = True
-- ^This is a Haddock documentation comment for the preceding code
{-|
This is a Haddock documentation block comment
-}
i code = True
Haxe
// Single line commment.
/*
Multiple
line
comment.
*/
HicEst
! a comment starts with a "!" and ends at the end of the line
Hope
! All Hope comments begin with "!" and extend to the end of the line
HTML
<!-- Anything within these bracket tags is commented, single or multi-line. -->
Icon and Unicon
Any text after "#" is a comment.
The The Icon Programming Library established conventions for commenting library additions and functions. This included both header block comments and meta comments on procedures within library files.
IDL
The comment character in IDL is the semicolon - everything starting with it and to the end of the line is a comment. Like this:
; The following computes the factorial of a number "n"
fact = product(indgen( n )+1) ; where n should be an integer
Inform 7
[This is a single-line comment.]
[This is a
multi-line comment.]
[Comments can [be nested].]
Insitux
;this is a comment; and using semicolons here is fine
(+ 2 2) ;this is a comment
"this string will be ignored if in the top scope
which can also stretch across
multiple lines"
(do "if you're desperate, using do will make sure this string will not be returned also"
(+ 2 2))
Intercal
PLEASE NOTE This is a comment
Io
# Single-line comment
// Single-line comment
/* Multi-line
comment */
Isabelle
theory Text
imports Main
begin
(* Top-level Isar comment. *)
end
J
NB. Text that follows 'NB.' has no effect on execution.
'Character strings in J may have their value be ignored and treated as comment text.'
0 : 0
Multi-line comments may be placed in strings,
like this.
)
Note 'example'
Another way to record multi-line comments as text is to use 'Note', which is actually
a simple program that makes it clearer when defined text is used only to provide comment.
)
{{)n
J release 9's nestable blocks can be used as comments.
Typically, this would be in contexts where the blocks would not be used.
That said, "literate coding practices" may stretch the boundaries here.
Also, noun blocks (beginning with ')n') avoid syntactic concerns about content.
These blocks even allow contained '}}' sequences to be ignored (unless, of
course the }} character pair appears at the beginning of a line).
}}
Java
Java has two ways to enter normal comments, plus a third type of comment that doubles as a way to generate HTML documentation.
C Style
/* This is a comment */
/*
* This is
* a multiple
* line comment.
*/
This C-style comment starts with /* and ends with */. The two delimiters may be on the same or separate lines. This style comment may be used anywhere white space is permitted.
C++ Style (inline)
// This is a comment
This C++-style comment starts with // and extends to the end of line.
Java Documentation (Javadoc)
/** This is a Javadoc comment */
/**
* This is
* a multiple
* line Javadoc comment
*/
Javadoc is a standardized documentation code for Java. Its comments begin with a forward slash and two stars. Javadoc comments have different tags that signify different things in the methods and classes that they precede.
Sneaky
Your editor will probably colour this as great big comment, but it compiles and prints "Hello World!". Once you've figured out how this works, try this discussion on why it's allowed.
public class JustComments {
/*
\u002A\u002F\u0070\u0075\u0062\u006C\u0069\u0063\u0020\u0073\u0074\u0061\u0074\u0069\u0063
\u0020\u0076\u006F\u0069\u0064\u0020\u006D\u0061\u0069\u006E\u0028
\u0053\u0074\u0072\u0069\u006E\u0067\u005B\u005D\u0061\u0072\u0067\u0073\u0029
\u007B\u0053\u0079\u0073\u0074\u0065\u006D\u002E\u006F\u0075\u0074\u002E
\u0070\u0072\u0069\u006E\u0074\u006C\u006E\u0028\u0022\u0048\u0065\u006C\u006C\u006F\u0022
\u002B\u0022\u0020\u0057\u006F\u0072\u006C\u0064\u0021\u0022\u0029\u003B\u007D\u002F\u002A
*/
}
JavaScript
n = n + 1; // This is a comment
// This is a valid comment // with a "nested" comment
/* This is
a multi line
comment
// with a "nested" comment
and another line in the comment
*/
JCL
first form
//* This is a comment line (//* in columns 1-3)
second form
/* This is also a comment line (/* in columns 1-3)
Joy
# this is a single line comment
(* this is a
multi-line comment *)
Multi-line comments cannot be nested.
jq
Except when a hash symbol (#) appears within a string, it begins a comment that continues to the end of the line:
# this is a single line comment
"Hello #world" # the first # on this line is part of the jq program
Jsish
#!/usr/bin/env/jsish
/* Comments, in Jsish */
// to end of line comment, double slash
/*
Enclosed comment, slash star, ending with star slash
Cannot be nested, but can cross line boundaries and occur
pretty much anywhere whitespace is allowed
*/
var x = 'X'; /* A var called X */
/* active code on this line */ printf("Result %q %d\n", /* comment code mix */ x, /**/42);
;x;
// jsish also handles double slash commented
// unit test echo lines as a special case of "expect failure"
;//noname(x);
/*
=!EXPECTSTART!=
Result X 42
x ==> X
noname(x) ==>
PASS!: err = can not execute expression: 'noname' not a function
=!EXPECTEND!=
*/
- Output:
prompt$ jsish comments.jsi Result X 42 prompt$ jsish --U comments.jsi Result X 42 x ==> X noname(x) ==> PASS!: err = can not execute expression: 'noname' not a function prompt$ jsish -u comments.jsi [PASS] comments.jsi
Julia
# single line
#=
Multi-
line
comment
=#
K
/ this is a comment
2+2 / as is this
KonsolScript
//This is a comment.
//This is another comment.
/* This is a comment too. */
/* This is a
multi-line
comment */
Kotlin
// This is a single line comment
/*
This is a
multi-line
comment
*/
/*
Multi-line comments
/*
can also be nested
*/
like so
*/
const val CURRENT_VERSION = "1.0.5-2" // A comment can also be added at the end of a line
const val /* or even in the middle of a line */ NEXT_MAJOR_VERSION = "1.1"
/**
* This is a documentation comment used by KDoc.
*
* It's documenting the main function which is the entry-point to a Kotlin executable.
*
* @param [args] A string array containing the command line arguments (if any) passed to the executable
* @return Implicit return value is Unit which signifies no meaningful return value (like 'void' in java)
*/
fun main(args: Array<String>) {
println("Current stable version is $CURRENT_VERSION")
println("Next major version is $NEXT_MAJOR_VERSION")
}
Lambdatalk
Out of bracketed expressions words are ignored by the lambdatalk evaluator and are dislayed as they are:
Hello World
-> Hello World
In order to prevent any evaluation and display of some parts of code put them inside triple degrees "°°°":
°°°
this is
a comment ... and an expression {+ 1 2}
on several lines
°°°
LabVIEW
This image is a VI Snippet, an executable image of LabVIEW code. The LabVIEW version is shown on the top-right hand corner. You can download it, then drag-and-drop it onto the LabVIEW block diagram from a file browser, and it will appear as runnable, editable code.
Lang
Single line
# This is a comment
Multiline (Line continuation)
# This is a comment\
with multiple lines
Multiline (Multiline text sequence)
# {{{This is a comment
which has more than
2 lines
and this one}}}
Lang5
# This is a comment.
langur
Langur has 2 types of comments.
# single line comment starts with hash mark
/* inline or multi-line comment uses C-style syntax */
Lasso
//This is a comment.
/* This is also a comment. */
/* A multi-line
comment */
/* ==========================
A multi-line
comment
=========================== */
LaTeX
In LaTeX, comments look like this:
\documentclass{minimal}
\begin{document}
% This is a comment
\end{document}
LaTeX comments start with % and continue up to and including the line break. The fact that the line break itself is commented out as well makes it useful for adding line breaks in the source code of complex macros without LaTeX interpreting them (which may cause extra space or even a paragraph break in the resulting typeset text). For example, the following results in the one word "understandable":
\documentclass{minimal}
\newcommand{\firstpart}[1]{under#1}
\newcommand{\secondpart}{able}
\newcommand{\complete}{%
\firstpart{stand}%
\secondpart}
\begin{document}
\complete
\end{document}
Without the percent sign after \firstpart{stand}, it would have been the two words "understand able".
Liberty BASIC
'This is a comment
REM This is a comment
print "This has a comment on the end of the line." 'This is a comment
print "This also has a comment on the end of the line." : REM This is a comment
Lily
There are two kinds of comments:
# This is a single-line comment
and
#[ This
is
a
block
comment ]#
Like with C, block comments don't nest.
LilyPond
% This is a comment
%{ This is a comment
spanning several lines %}
Lingo
In Lingo any line starting with "--" is a comment and ignored by the interpreter.
-- This is a comment.
-- This is another comment
LiveCode
-- comment may appear anywhere on line
// comment may appear anywhere on line
# comment may appear anywhere on line
/* this is a
block comment that
may span any number of lines */
Logo
; comments come after a semicolon, and last until the end of the line
Logtalk
% single-line comment; extends to the end of the line
/* multi-line
comment */
LOLCODE
OBTW This is a
multi line comment
TLDR
BTW This is a single line comment.
LotusScript
LotusScript has two ways to enter comments.
' This is a comment
Wherever the single quote (') is used, the rest of the line is treated as a comment and ignored. Multi-line comments would each need a single quote mark. This style of comment is usually used for making small in-line or single line comments.
%REM
This is a multi-
line comment.
%END REM
A %REM marker begins a comment block, and a %END REM marker ends the comment block. This style of comment is used for making longer multi-line comments, often at the beginning of a class, sub or function.
LSE
* Ceci est un commentaire qui prend fin quand la ligne se termine
(* Ceci est un commentaire sur plusieurs lignes
comme vous pouvez le voir puisqu'il s'étend sur
plusieurs lignes justement... *)
(* Cette exemple est selon la revision LSE-2000 *)
LSE64
# single line comment (space after # is required)
The author of LSE64 comments the stack effect of words with header comments as follows:
# arg1 arg2 '''yields''' result|''nothing''
Lua
-- A single line comment
--[[A multi-line
comment --]]
--[====[ A multi-line comment that can contain [[ many square brackets ]]
]====]
M2000 Interpreter
Multiline commend Ret { lines of code, or text }
Same line comment until end of line (can start immediate after a command: use ' or \ or //
Rem (form start of code line)
(:\ and \\ or \) in a name can exist only for Dir statement:
dir c:\thatfolder
is the same as
dir "c:\thatfolder"
Module Comments {
Rem {
Print "no print here"
? "no print here either"
}
Rem : single line remark
// single line
\ single line
' single line
? "ok" : Rem : Print "not print - but code have syntax highlight"
? "ok" // single line - start without double colon
? "ok" \ single line - start without double colon
Print "ok" ' single line
}
Comments
M4
eval(2*3) # eval(2*3) "#" and text after it aren't processed but passed along
dnl this text completely disappears, including the new line
divert(-1)
Everything diverted to -1 is processed but the output is discarded.
A comment could take this form as long as no macro names are used.
divert
- Output:
6 # eval(2*3) "#" and text after it aren't processed but passed along
dnl
must be a separate word.
An empty pair of quotes
can separate it from preceding text if necessary
some text`'dnl then a deleted comment
changecom()
can set a different character for #
,
changecom(%)
% now percent prevents macro expansion
In GNU m4 an empty changecom()
string means no such commenting char at all (but in BSD m4 means reset to the default #
)
changecom()
GNU m4 now no macro expansion suppression character at all
In GNU m4 changecom()
also takes separate start and end strings and they can be multi-character sequences, allowing for example C style,
changecom(/*,*/)
/* GNU m4 now no macro expansion in C style comments */
Maple
x := 4: x; # Everything on this line, after this, is a comment.
17; (* This
is
a multiline comment *) 23.4;
- Output:
4 17 23.4
Mathematica / Wolfram Language
(*this is a comment*)
It can be used everywhere and nested if necessary:
If[a(*number 1*)<(* is smaller than number 2*) b, True (*return value (*bool true*)*), False (*return bool false*)]
evaluates to:
If[a < b, True, False]
MATLAB
%This is a comment
%% Two percent signs and a space are called a cell divider
Maxima
/* Comment
/* Nested comment */
*/
MAXScript
-- Two dashes precede a single line comment
/* This is a
multi-line comment */
MBS
! A pling in a line starts a comment
INT n:=5 ! Comments can appear at the end of a line
/* A comment block can also be defined using climbstar and starclimb symbols.
This allows comments to be stretched across several lines */
MEL
// This is a single line comment
Metafont
% this is "to-end-of-line" comment
Microsoft Small Basic
Microsoft Small Basic uses the quote symbol to mark it's comments. After placing a quote everything in that line will be ignored.
' This is a comment
i = i + 1 ' You can also append comments to statements
min
; this is a comment
1 1 + ; add one and one together
MiniScript
MiniScript just has one kind of comment. They begin with two slashes, and extend to the end of a line. So you can put a comment either on a line by itself, or after a statement.
// How many roads must a man walk down?
x = 6 * 7 // forty-two
Mirah
puts 'code' # I am a comment
/* This is
* a multiple
* line comment */
MIPS Assembly
This is ultimately up to the assembler, but semicolons are typically the comment character for almost all assemblers.
;this is a comment
li $t0,0x1234 ;this is also a comment
However, MARS and QTSPIM use the #
.
# this is a comment
li $t0,0x1234 # this is also a comment
mIRC Scripting Language
;Single Line Comment
/*
Multiple
Line
Comment
*/
Modula-2
(* Comments (* can nest *)
and they can span multiple lines.
*)
Modula-3
(* Comments (* can nest *)
and they can span multiple lines.
*)
Monte
# This comment goes to the end of the line
/** This comment is multi-line.
Yes, it starts with a two stars
and ends with only one.
These should only be used for docstrings. */
MontiLang
/# This is a comment #/
/#
comments can span multiple lines
nested comments are not supported #/
MOO
"String literals are technically the only long-term comment format";
// Some compilers will, however, compile // one-liners to string literals as well (and vice-versa)
/* Classical C-style comments are removed entirely during compile */
Nanoquery
Comments in Nanoquery must be on a single line.
// this is a comment
// this is also a comment
NATURAL
* This is a comment and extends to the end of the line
Neko
// Single line comment, of course!
/*
Multi line comment!
*/
/**
Documentation block
<doc>can include XML parsed nodes between doc tags</doc>
**/
Nemerle
// This comment goes up to the end of the line
/* This
is
a
multiline
comment */
NESL
% This is a comment. %
NetRexx
NetRexx supports block-comments and line comments. Block comments are started with a /*
and terminated with a */
. Line comments follow a --
sequence anywhere on a line.
NetRexx supports nested comments (see REXX).
/*
NetRexx comment block
*/
-- NetRexx line comment
NewLISP
A comment is started by ;
and reaches to the end of the line.
; This is a comment
Nim
# Nim supports single-line comments
var x = 0 ## Documentation comments start with double hash characters.
var y = 0 ## Documentation comments are a proper part of the syntax (they're not discarded by parser, and a real part of AST).
#[
There are also multi-line comments
Everything inside of #[]# is commented.
]#
# You can also discard multiline statements:
discard """This can be considered as a "comment" too
This is multi-line"""
Nix
# This comment goes up to the end of the line
/* This
is
a
multiline
comment */
NSIS
# This is a comment that goes from the # to the end of the line.
; This is a comment that goes from the ; to the end of the
/* This is a
multi-line
comment */
Oberon-2
(* this is a comment *)
(*
and this is a
multiline comment
(* with a nested comment *)
*)
Objeck
#This is a comment.
# This is other comment.
#~ This is a comment too. ~#
#~ This is a
multi-line
comment ~#
Objective-C
- See C
OCaml
(* This a comment
(* containing nested comment *)
*)
(** This an OCamldoc documentation comment *)
Octave
# I am a comment till the end of line
% I am a comment till the end of line
%{
This comment spans
multiple lines
%}
Oforth
Oforth has only single line comment (inside or outside definition)
// This is a comment...
ooRexx
Comments in ooRexx follow the same rules as REXX and NetRexx
/*
Multi-line comment block
*/
-- this type of comment works in ooRexx, NetRexx and some of the more popular REXX implementations like Regina
hour = 0 -- which is, like midnight, dude.
hour = 12 /* time for lunch! works as well (and really everywhere) */
Openscad
The openscad geometry compiler supports C++ style comments:
// This is a single line comment
/*
This comment spans
multiple lines
*/
OxygenBasic
' Basic line comment
; Assembly code line comment
// C line comment
/* C block comment */
Oz
% one line comment
%% often with double "%" because then the indentation is correct in Emacs
/* multi line
comment
*/
PARI/GP
Comments are similar to C. The block comment is identical: /* comment */
. The line comment uses backslashes instead of slashes: \\ comment
.
Pascal
(* This is a comment.
It may extend across multiple lines. *)
{ Alternatively curly braces
can be used. }
(* This is a valid comment in Standard Pascal,
but not valid in [[Turbo Pascal]]. }
{ The same is true in this case *)
In Pascal, comments cannot be nested.
PascalABC.NET
(* This is a
multiline comment *)
{ This is also a
multiline comment }
// This is a single line comment
PASM
# This is a comment
print "Hello\n" # This is also a comment
end
Peloton
Peloton encloses all comments inside <@ OMT></@> (fixed length opcode) or <# OMIT></#> (variable length opcode) whether single- or multi- line.
<@ OMT>This is a
multiline
comment</@>
OMT suppresses evaluation of everything contained. There are a variety of extra opcodes which can be used to control how OMT functions at run time.
Perl
Single line comment
# this is commented
These may also be at the end of a line
my $var = 1; # this is the comment part
Multi-line comments for inline documentation (Plain Old Documentation, or POD in Perl parlance) follow the format:
=pod
Here are my comments
this is multi-line
=cut
Note that technically, both of the lines beginning with the equals sign must be surrounded on either side for compatibility with all "POD" parsers.
Note also that any string beginning with an equals sign, and that appears in the initial column of a line, begins a multi-line comment. It does not have to be a POD "command:" the following are all valid:
=head1
=head4
=over 4
=Any Old String
Such blocks always end in =cut.
For more info, type at a command prompt (or into a search engine): "perldoc perlpod"
Phix
Single line comment:
-- this is a comment.
// this is also a comment.
Nestable multiline comments:
/* This is a comment procedure oldproc() /* This is also a comment */ puts(1,"kill me now") end procedure */ puts(1,"this is not a comment")
- Output:
this is not a comment
In fact there are now a total of six(!) different types of comment in Phix:
#! opening shebang #[ .. #] for multiline shebangs -- standard line comments // C-style line comments /* .. */ standard nestable multiline comments --/* .. --*/ Euphoria-compatibility-style nestable multiline comments/code
PHP
Single line comment:
# this is commented
// this is commented
These may also be at the end of a line:
$var = 1; # this is the comment part
$var = 1; // this is the comment part
Basic syntax for multi-line comments:
/*
Here are my comments
this is multi-line
*/
Note that; it is more common to see phpDocumentor styled multi-lined comments:
/**
* phpdoc Comments
* @todo this is a todo stub
*/
Picat
/*
* Multi-line comment
*/
% Single-line Prolog-style comment
PicoLisp
# The rest of the line is ignored
#{
This is a
multiline comment
}#
NIL
Immediately stop reading this file. Because all text in the input file following
a top-level 'NIL' is ignored.
This is typically used conditionally, with a read-macro expression like
`*Dbg
so that this text is only read if in debugging mode.
Pike
// This is a comment.
/* This is a
multi
line
comment */
int e = 3; // end-of-statement comment.
PL/I
/* This is a comment. */
/*
This is a multiline comment.
*/
Note: In PL/I, comments cannot be nested.
PL/SQL
Single line comment:
--this is a single line comment
Multiline comment:
/*
this is a multiline
comment
*/
End of line comment:
v_var number; --this is an end of line comment
Plain English
\A comment like this lasts until the end of the line
Put 1 plus [there are inline comments too] 1 into a number.
Plain TeX
The default raw/bare TeX assigns the category code 14 (comment character) to the character %, and plainTeX, as also LaTeX (see here Comments in LaTeX, does not change it; so the % starts a to-end-of-line comment in many TeX macro packages.
% this is a comment
This is not.
The final newline character is eaten and since it normally behaves like a space, the comment can be used to hide the newline:
\def\firstpart#1{under#1}
\def\secondpart{able}
\def\complete{\firstpart{stand}%
\secondpart}
\complete
Outputs understandable; without % it would output understand able.
Pop11
Pop11 has two kinds of comments: endline and C-like. Endline comment begins with tree consecutive semicolons and ends at the end of line:
;;; This is a comment
C-like comments may be multiline:
/* First line
Second line */
C-like comments (unlike C) may be nested:
/* This is a comment /* containing nested comment */ */
One can also use conditional compilation to comment out sections of code
#_IF false
some code
#_ENDIF
however, commented out part must consist of valid Pop11 tokens. In particular, C-like comments must balance and strings must be terminated. The following is an error:
#_IF false
This w'ont work
#_ENDIF
because apostrophe starts an unterminated string.
PostScript
%This is a legal comment in PostScript
PowerShell
# single-line comment
<# multi-line
comment #>
Processing
// a single-line comment
/* a multi-line
comment
*/
/*
* a multi-line comment
* with some decorative stars
*/
// comment out a code line
// println("foo");
// comment at the end of a line
println("foo bar"); // "baz"
Processing Python mode
# a single-line comment
"""
Not strictly a comment, bare multi-line strings are used
in Python as multi-line comments. They are also used as
documentation strings or 'docstrings' when placed as the
first element inside function or class definitions.
"""
# comment out a code line
# println("foo")
# comment at the end of a line
println("foo bar") # "baz"
# there is no way to make an inline comment
ProDOS
I don't know why this is even a task because it should be included in any decent programming language.
IGNORELINE your text here
ProgressBASIC
10 REM I AM A COMMENT
Prolog
% this is a single-line comment that extends to the end of the line
/* This is a
multi-line comment */
PureBasic
PureBasic uses the ";" symbol to mark its comments. All text entered after ";" on a line is ignored by the compiler.
;comments come after an unquoted semicolon and last until the end of the line
foo = 5 ;This is a comment
c$ = ";This is not a comment" ;This is also a comment
Python
Python uses the "#" symbol to mark it's comments. After placing a "#", everything to the right of it in that line will be ignored.
# This is a comment
foo = 5 # You can also append comments to statements
Certain 'do nothing' expressions resemble comments
"""Un-assigned strings in triple-quotes might be used
as multi-line comments
"""
'''
"triple quoted strings" can be delimited by either 'single' or "double" quote marks; and they can contain mixtures
of other quote marks without any need to \escape\ them using any special characters. They also may span multiple
lines without special escape characters.
'''
Note that strings inserted among program statements in Python are treated as expressions (which, in void context, do nothing). Thus it's possible to "comment out" a section of code by simply wrapping the lines in "triple quotes" (three consecutive instances of quotation marks, or of apostrophes, and terminated with a matching set of the same). Using unassigned strings as comments is frowned on and may also trigger certain linters.
Documentation Strings
Python makes pervasive use of strings which immediately follow class and function definition statements, and those which appear as the first non-blank, non-comment line in any module or program file. These are called "documentation" strings or "docstrings" for short; and they are automatically associated with the __doc__ attribute of the class, function, or module objects in which they are defined. Thus a fragment of code such as:
#!/usr/bin/env python
# Example of using doc strings
"""My Doc-string example"""
class Foo:
'''Some documentation for the Foo class'''
def __init__(self):
"Foo's initialization method's documentation"
def bar():
"""documentation for the bar function"""
if __name__ == "__main__":
print (__doc__)
print (Foo.__doc__)
print (Foo.__init__.__doc__)
print (bar.__doc__)
... would print each of the various documentation strings in this example. (In this particular example it would print two copies of the first doc string which because __doc__ in the "current" name space is the same as __main__.__doc__ when our program is running as a script). If some other script were to import this file (under the name "example" perhaps) then "My Doc-string example" would be the value of example.__doc__
Python "docstrings" are used by a number of tools to automatically generate documentation (for most of the Python standard libraries, classes, functions, etc, as well as for user programs which define docstrings). They are also used by tools such as doctest to automatically derive test suites from properly formatted examples of class instantiations, function invocations and other usage samples. The standard pydoc utility can search through Python source trees generating documentation and can function as a local web server allowing a programmer to browse "live" hyperlinked documentation of their project.
(As noted above extraneous strings interspersed throughout a Python source file can be used as comments, though this is rarely done in practice; only those strings which lexically follow the definition of a class, function, module or package are assigned to __doc__ attributes in their respective name spaces).
Quackery
( The word "(" is a compiler directive (a builder,
in Quackery jargon) that causes the compiler to
disregard everything until it encounters a ")"
preceded by whitespace.
If you require more than that, it is trivial to
define new comment builders... )
[ behead carriage = until ] builds #
# Now the word "#" will cause the compiler to
# disregard everything from the "#" to the end of
# the line that it occurs on.
[ drop $ "" ] builds commentary
commentary
The word "commentary" will cause the compiler to
disregard everything that comes after it to the
end of the source string or file.
QB64
CBTJD: 2020/03/12
REM This is a remark...
' This is also a remark...
IF a = 0 THEN REM (REM follows syntax rules)
IF a = 0 THEN '(apostrophe doesn't follow syntax rules, so use END IF after this)
END IF
'Metacommands such as $DYNAMIC and $INCLUDE use the REM (or apostrophe).
REM $STATIC 'arrays cannot be resized once dimensioned.
REM $DYNAMIC 'enables resizing of array dimensions with REDIM.
REM $INCLUDE: 'loads a reference file or library.
R
# end of line comment
Racket
; this is a to-end-of-line coment
#| balanced comment, #| can be nested |# |#
#;(this expression is ignored)
#; ; the following expression is commented because of the #; in the beginning
(ignored)
Raku
(formerly Perl 6)
Single-line comments
A single-line comment starts with # and extends to the end of the line.
# the answer to everything
my $x = 42;
Multi-line comments
A multi-line comment starts with #` and followed by the commented text enclosed by bracketing characters (e.g., (), [], {}, 「」, etc.).
#`(
Comments beginning with a backtick and one or more opening bracketing characters are embedded comments.
They can span more than one line…
)
my $y = #`{ …or only part of a line. } 3;
Multi-line comments can also be embedded into code.
for #`(each element in) my @array {
say #`(or print element) $_ #`(with a newline);
}
Using more than one bracketing character lets you include an unmatched close bracket, as shown below.
#`{{
This close curly brace } won't terminate the comment early.
}}
Pod comments
=begin comment
Pod is the successor to Perl 5's POD. This is the simplest way to use it for multi-line comments.
For more about Pod, see Pod: https://docs.perl6.org/language/pod
=end comment
Pod also provides declarator blocks which are special comments that attach to some source code and can be extracted as documentation. They are either #| or #= and must be immediately followed by either a space or an opening curly brace. In short, blocks starting with #| are attached to the code after them, and blocks starting with #= are attached to the code before them.
#| Compute the distance between two points in the plane.
sub distance(
Rat \x1, #= First point's abscissa,
Rat \y1, #= First point's ordinate,
Rat \x2, #= Second point's abscissa,
Rat \y2, #= Second point's ordinate,
){
return sqrt((x2 - x1)**2 + (y2 - y1)**2)
}
Rapira
Comments in Rapira are preceded by a backslash (\).
\ This is a Rapira comment.
Raven
# this is a comment
REBOL
; This is a line comment.
{ Multi-line strings can
be used as comments
if you like }
Functions have special commenting options which make them self documenting:
plus2: func [
"Adds two to a number."
n [number!] "The number to increase."
][
n + 2
]
If you say "help plus2" at REBOL's REPL, you'll get this help information:
USAGE: PLUS2 n DESCRIPTION: Adds two to a number. PLUS2 is a function value. ARGUMENTS: n -- The number to increase. (Type: number)
Relation
// This is a valid comment
// A space is needed after the double slash
Retro
( comments are placed between parentheses. A space must follow the opening parenthesis. )
REXX
It should be noted that comments in the REXX language support nested comments, so comments aren't totally ignored by the REXX interpreter (and compiler).
REXX comments are scanned and preserved for use by the sourceline BIF. [The sourceline BIF allows the retrieval of any or all lines of source (of the REXX program).]
Also, redundant blanks are removed and processed/shown for various trace options (trace is a REXX statement that may show various interpretation/execution stages of REXX statements (clauses, values, etc.), including comments and also blank lines). The trace statement is also used for interactive debugging.
Nested comments must have matching delimiters, so the contents of the comments can't just be willy-nilly characters.
Also, some REXX interpreters show the comment (if part of a REXX statement) as part of the information displayed when (if) a syntax error occurs and an informative error message is generated. For instance, in the program (named c:\COMMENTD.REX):
/*REXX program that demonstrates what happens when dividing by zero. */
y=7
say 44 / (7-y) /* divide by some strange thingy.*/
output when using the Regina REXX interpreter:'
3 +++ say 44 / (7-y) /* divide by some strange thingy.*/ Error 42 running "c:\COMMENTD.REX", line 3: Arithmetic overflow/underflow Error 42.3: Arithmetic overflow; divisor must not be zero
output when using the R4 REXX interpreter:'
Error 42 : Arithmetic overflow/underflow (SYNTAX) Information: Divide by zero Error occurred in statement# 3 Statement source: say 44/(7-y) Statement context: c:\commentdv.rex, procedure: commentdv
output when using the Personal REXX interpreter:'
3 +++ say 44 / (7-y) /* divide by some strange thingy.*/ Error 42 on line 3 of C:\COMMENTD.REX: Arithmetic overflow/underflow
The REXX language was heavily modeled after PL/I, both languages have the same comment construct, but PL/I doesn't support nested comments.
Nested comments allow an easy way to comment large chunks of code where the commented-out code has its own comments.
/*REXX program to demonstrate various uses and types of comments. */
/* everything between a "climbstar" and a "starclimb" (exclusive of literals) is
a comment.
climbstar = /* [slash-asterisk]
starclimb = */ [asterisk-slash]
/* this is a nested comment, by gum! */
/*so is this*/
Also, REXX comments can span multiple records.
There can be no intervening character between the slash and asterisk (or
the asterisk and slash). These two joined characters cannot be separated
via a continued line, as in the manner of:
say 'If I were two─faced,' ,
'would I be wearing this one?' ,
' --- Abraham Lincoln'
Here comes the thingy that ends this REXX comment. ───┐
│
│
↓
*/
hour = 12 /*high noon */
midnight = 00 /*first hour of the day */
suits = 1234 /*card suits: ♥ ♦ ♣ ♠ */
hutchHdr = '/*'
hutchEnd = "*/"
/* the previous two "hutch" assignments aren't
the start nor the end of a REXX comment. */
x=1000000 ** /*¡big power!*/ 1000
/*not a real good place for a comment (above),
but essentially, a REXX comment can be
anywhere whitespace is allowed. */
A Classic REXX implementation (e.g. Regina) also allow line comments which start with a -- sequence and extend to the end of the line:
[Note: Regina REXX releases since 3.4 allow this type of single-line comment only if the option Single_Line_comments isn't present in the REGINA_OPTIONS environmental variable. So, Regina may allow the use of single-line comments, depending upon which release is being used. That is to say, one can't depend (or assume) that the Regina extension (of single-line comments) for the aforementioned option will be or not be present (supported and/or allowed) in the environment being used]. Which means one could set this option to their preference if using Regina REXX later than version 3.3.
Since Single-Line comments aren't part of the ANSI standard nor a part of the Classic REXX language, the use of which would make the REXX code non-portable.]
-- A REXX line comment (maybe)
say "something" -- another line comment (maybe)
It should be noted that the above type of comments are not part of Classic REXX, nor are they described nor sanctioned in the REXX ANSI standard.
Ring
in Ring language we can use // or # for one line comments:
//this is a single line comment
#this also a single line comment!
and for multi-line comments we use /* */:
/*This is a multi-line
comment that will be completely
ignored by the compiler/interpreter
*/
RLaB
RLaB only has single line comment indicator, as in following examples
x = "code" # I am a comment
x = "code" // Here I comment thee
# matlab-like document line
// C++ like document line
Robotic
Comments can only be created in one way:
. "This is a comment line"
. "Print Hello world"
* "Hello world."
. "This is the only way to comment a line in Robotic"
Although these are comments, the interpreter doesn't completely ignore it. For one, the code speed can be affected if they are ever encountered. Also, if an @ character exists at the beginning of the comment line, then the rest of the string after it is now the Robot's new name (there is a 14 character limit).
Example of changing the robot's name:
. "@NewRobotName"
This would then change the robot's name from whatever it was before to "NewRobotName" instead.
Rockstar
Rockstar is cool.
(Rockstars don't like comments, but if you really really want to, you write them in parentheses and they are believed to be multiline. In fact, parentheses are just the comment symbols, so you can't even use parentheses in math, so if you want the addition to happen before the multiplication, do the addition and assign it to a variable. And by the way, the Rockstar is cool line assigned the number 4 to the variable Rockstar, because cool is four letters and all that. And this comment has gone on way too long for a language with a developer community that hates comments.)
Shout Rockstar.
(Might as well put that number 4 on the screen.)
RPL
Although its code can sometimes be difficult to read due to stack operations, basic RPL does not provide any functionality to comment out. The only solution is then to insert strings and delete them immediately, such as:
≪
SWAP - "swap the first 2 levels and subtract" DROP
≫
From 1993, comments can be added in a source code written with a text editor on a computer, starting with an @ and ending by either another @ or a newline character, before transfer to and compilation by the calculator. The compilation step removes all comments.
≪
SWAP - @ swap the first 2 levels and subtract
≫
Ruby
x = "code" # I am a comment
=begin hello
I a POD documentation comment like Perl
=end puts "code"
Run BASIC
Comments have a ' (single quote) or REM for remarks
'This is a comment
REM This is a comment
print "Notice comment at the end of the line." 'This is a comment
print "Also notice this comment at the end of the line." : REM This is a comment
Rust
// A single line comment
/*
This is a multi-line (aka block) comment
/*
containing nested multi-line comment
(nesting supported since 0.9-pre https://github.com/mozilla/rust/issues/9468)
*/
*/
/// Outer single line Rustdoc comments apply to the next item.
/**
Outer multi-line Rustdoc comments.
* Leading asterisk (*) in multi-line Rustdoc comments
* is not considered to be part of the comment text,
* blanks and tabs preceding the initial asterisk (*) are also stripped.
*/
fn example() {
//! Inner single line Rustdoc comments apply to their enclosing item.
/*!
Inner multi-line Rustdoc comments.
See also https://github.com/mozilla/rust/wiki/Doc-using-rustdoc
*/
}
#[doc = "Unsugared outer Rustdoc comments.
(outer attributes are not terminated by a semi-colon)"]
fn example() {
#[doc = "Unsugared inner Rustdoc comments.
(inner attributes are terminated by a semi-colon)
See also https://github.com/mozilla/rust/blob/master/doc/rust.md#attributes"];
}
SAS
/* comment */
*another comment;
* both
may
be
multiline;
Sather
-- a single line comment
S-BASIC
rem S-BASIC of course allows traditional BASIC-style comments
comment
In addition to the single-line REM statement, S-BASIC
also supports multiline comments using COMMENT...END.
Note that the terminating END must be the first token on
a line of its own.
end
comment
When declaring a group of variables, S-BASIC allows
a semi-colon, instead of the normal comma, as a separator,
in which event an explanatory comment can follow the
semi-colon and is ignored by the compiler.
end
var n ; number of payments over life of loan
ppy ; payments per year
apr ; annual interest rate as a decimal
amt ; principal amount of loan
pmt ; amount of periodic payment
= real
comment
Finally, although statements in S-BASIC are normally terminated
by an end-of-line, any logical statement can be continued on to
the following physical line with a backslash, in which event
anything after the backslash is ignored and can be used for
a comment.
end
if amt = 0 then \ user forgot to enter a value
print "Must specify a loan amount!"
end
Scala
// A single line comment
/* A multi-line
comment */
Scheme
; Basically the same as Common Lisp
; While R5RS does not provide block comments, they are defined in SRFI-30, as in Common Lisp :
#| comment
... #| nested comment
... |#
|#
; See http://srfi.schemers.org/srfi-30/srfi-30.html
Scilab
Specify a comment starting with // to the end of line
// this is a comment
i=i+1 // this is a comment
sed
# a single line comment
Seed7
# A single line comment
(* A multi-line
comment *)
(* In Seed7,
(* comments can be nested. *) *)
SenseTalk
# Hashtag is a comment
-- Dash dash is another comment
// Slash slash is yet another comment
— Alt/Option + Underscore creates an m-dash comment
(* Parentheses and star is used for commenting
blocks of code (* and can be nested *) *)
set foo to true // all comments can append to statements
Set lang
> Comments start where a > (greater than symbol) starts
set a 0 > Comments may start after a Set command
SETL
print("This is not a comment"); -- This is a comment
$ For nostalgic reasons, this is also a comment.
Sidef
Single line comment
# this is commented
These may also be at the end of a line
var i = 1; # this is the comment part
Embedded comments
var distance #`{in meters} = (30 #`{meters} * 100 #`{seconds});
say distance; # prints: 3000
Multi-line comments
/*
This is a multi-line comment
*/
Simula
The same as Algol 60:
COMMENT This is a comment for Simula 67;
And an new form:
!This is a comment for Simula 67;
Pitfall: it's not easy to comment-out parts of code:
!OutText("Dying."); !Outimage; !terminate_program;
Slate
"basically the same as smalltalk"
Smalltalk
"Comments traditionally are in double quotes."
"Multiline comments are also supported.
Comments are saved as metadata along with the source to a method.
A comment just after a method signature is often given to explain the
usage of the method. The class browser may display such comments
specially."
smart BASIC
'Single line comments are preceded by a single quote or the command REM
PRINT "Hello" 'Single line comments may follow code
PRINT "Hello" REM You can also use the command REM following code
/*
Multi-line comments
are surrounded by
mirrored slash
and asterisk
*/
/*Multi-line comments do not have to actually have multiple lines*/
/* Spaces before or after comment bounds are optional.*/
/* A comment can also follow another comment */ 'Like this
Some programmers like to do this to allow for /* Procedural comments */ followed by 'Programmer's notes.
SNOBOL4
* An asterisk in column 1 is the standard Snobol comment
* mechanism, marking the entire line as a comment. There
* are no block or multiline comments.
* Comments may begin at
* any position on the line.
- A hyphen in column 1 begins a control statement.
- Unrecognized control statements are ignored and
- may also mark comment lines. Not recommended.
;* The semicolon statement separator
output = 'FOO' ;* begins a new statement. This idiom
output = 'BAR' ;* simulates an asterisk in the first
;* column, allowing end of line comments.
END
Any text after the required END label is ignored.
SNUSP
As with Brainf*** and Befunge, any character that is not part of the language is ignored and can be used as commentary, and you can add comments anywhere the instruction pointer is not expected to traverse. Reserved characters are:
- Core: + - > < , . ? ! / \ $ #
- Modular: @ #
- Bloated: : ; & %
As a matter of convention, the characters '=' and '|' are used for spacing to indicate horizontal and vertical flow of control, respectively.
SPL
'This is single-line comment
''This is
multiline comment''
SQL
The double hyphen ( -- ) is used to include a comment on an SQL statement.
The comment appears on the same line as the statement:
SELECT * FROM mytable -- Selects all columns and rows
or before:
-- Selects all columns and rows
SELECT * FROM mytable
or after:
SELECT * FROM mytable
-- Selects all columns and rows
SQL PL
Single line comment:
--This is a single line comment.
Multiline comment:
/* This is
a multiline
comment */
Another way to do multiline comments
(= This is
a multiline
comment =)
End of line comment:
declare myvar number; --This is an end of line comment.
Comments work the same as in SQL.
Squirrel
//this is a single line comment
#this is also a single line comment
/*
this is a multi-line comment
*/
SSEM
The SSEM can only be programmed in pure binary, by setting front panel switches: the concepts of "text" and "source file" (both mentioned in the specification) are therefore not directly applicable to it. If binary numbers have any mnemonic or explanatory value for you, however, there is a way of including information in your program that the computer will ignore. This is a direct result of the machine's rather poor code density. Each 32-bit instruction word consists of (a) a five-bit address field giving the operand, (b) eight unused bits, (c) a three-bit instruction field giving the operation to be performed, and (d) sixteen more unused bits. If the instruction field is set to 011 Test or 111 Stop, even the address field is unused. In the case of a Sub. instruction, finally, the leftmost bit of the instruction field is disregarded: 001 and 101 both mean "subtract". We therefore have at least 24 and sometimes 25 or 29 bits in each instruction that we can, if we like, use for comments. The word
00101010010001000100100100001100
will be understood by the machine as Add 20 to CI, a normal instruction. But it also fits four comment characters into the unused bits, employing a simple five-bit encoding where A=0 and Z=25. The instruction breaks down as follows:
00101 -- address field = 20
01001 -- "comment" field = 18
000 -- three unused bits
100 -- instruction field = Add to CI
01001 -- "comment" field = 18
00100 -- "comment" field = 4
01100 -- "comment" field = 12
0 -- unused bit
Applying our simple alphabetic encoding, we see that the "spare" bits spell out 18, 18, 4, 12 = S, S, E, M.
More realistically, you can include comments when you are drafting your program using mnemonic notation and then simply leave the comments out when it comes time to toggle the program in.
Standard ML
(* This a comment
(* containing nested comment *)
*)
Stata
* Line comment: must be used at the beginning of a line (does not work in Mata)
// Line comment until the end of the line
/* Multiline comment
*/
SuperTalk
-- This is a comment
Swift
// this is a single line comment
/* This a block comment
/* containing nested comment */
*/
///This is a documentation comment
/**
This is a documentation block comment
*/
Symsyn
| This is a comment
Tcl
Tcl follows the usual scripting language rules: a comment starts at a "#" symbol, which can be placed after a command if that is terminated by a semicolon:
# comment on a line by itself. The next is a command by itself:
set var1 $value1
set var2 $value2 ; # comment that follows a line of code
The reason for the need for a semi-colon on a trailing comment is this:
"If a hash character (“#”) appears at a point where Tcl is expecting the first character of the first word of a command, then the hash character and the characters that follow it, up through the next newline, are treated as a comment and ignored. The comment character only has significance when it appears at the beginning of a command." (from the Tcl man page -- emphasis mine)
The "#" symbol has no special meaning if it is not where a command would appear -- it's just data. (Syntax highlighters often get this wrong.)
set aList {foo}
lappend aList # bar
puts $aList ;# ==> prints "foo # bar"
puts [llength $aList] ;# ==> 3
TCL has no native multi-line comment format. However, in most circumstances, a multi-line comment can be faked by wrapping it within a block that will never be executed:
if 0 {
Comments...
}
Tern
- See Java
TI-83 BASIC
There is no 'proper' way of adding comments in TI-BASIC, however there are ways to add text to a program that will be ignored by the calculator.
One common approach is to put the comment in a string which is not stored anywhere:
:"THIS IS A COMMENT
However this will change the Ans variable.
This approach, while messier, does not affect the Ans variable:
:If 0
:THIS IS A COMMENT
TI-89 BASIC
© This is a comment. Everything from © to the end of the line is ignored.
Tiny BASIC
10 REM this is a comment
20
40 REM from above you can see that line numbers with no statement
50 REM and blank lines also are ignored
Toka
There are two ways to add comments in Toka. For full lines, or at the end of a line, the shebang is normally used:
#! Everything on this line (after the shebang to the left) will be ignored.
The shebang comments can not be used inside of functions.
In addition, Toka also accepts parenthetical comments. These are enclosed in parenthesis, and are often used for stack comments or comments inside functions.
[ ( a b -- c )
... ] is myword
In addition, parenthetical comments can span multiple lines.
( This is a
simple, multi-line
comment )
Since comments are provided by actual functions, the comment function must be whitespace delimited, just as with all other functions in Toka.
A final way to include text in a file is to mark a false ending with end.
... code ....
end.
Nothing following the end. will be evaluated by Toka.
TorqueScript
//This is a one line comment. There are no other commenting options in TorqueScript.
TPP
--## comments are prefixed with a long handed double paintbrush
Transd
// This is a line comment.
/* This is a single line block comment.*/
/* This is
a multi-line
block comment.*/
TUSCRIPT
$$ MODE TUSCRIPT
- This is a comment
TXR
@# old-style comment to end of line
@; new-style comment to end of line
@(bind a ; comment within expression
"foo")
UNIX Shell
#!/bin/sh
# A leading hash symbol begins a comment.
echo "Hello" # Comments can appear after a statement.
# The hash symbol must be at the beginning of a word.
echo This_Is#Not_A_Comment
#Comment
C Shell
#!/bin/csh -f
# C Shell has a similar comment syntax, but only allows comments in a
# script file, not in terminal input.
echo Hello#With C Shell, the hash can also be in the middle of a word.
es
# Comments in es (extensible shell) look like those of other shells.
echo Hello#With es, the hash can also be in the middle of a word.
Unlambda
Unlambda comments start with #
and extend to the end of the line:
# this is a comment.
Note that comments don't need to start at the beginning of a line, e.g.
` # apply .a # output "a" i # identity
is equivalent to
`.ai
Ursa
Comments in Ursa must be on a single line, and are denoted by a #
# this is a comment
# this is another comment
Ursala
There are lots of ways to have comments in Ursala. Here are the conventional ones.
# this is single line a comment
# this is a\
continued comment
(# this is a
multi-line comment #)
(# comments in (# this form #) can (#
be (# arbitrarily #) #) nested #)
---- this is also a comment\
and can be continued
###
The whole rest of the file after three hashes
is a comment.
Commenting out code
There are also ways to comment out sections of code during testing. An individual item of a syntactically correct list or aggregate is commented out like this.
x = <1,## 2,3>
The 2 is ignored but 1 and 3 aren't. This also works with nested aggregates and multiple lines.
a =
<
'to',
## <
'be',
'or'>,
'not',
'to',
## 'be'>
A syntactically correct declaration can be commented out like this.
foo = 1
##
bar = 2
baz = 3
As far as the compiler is concerned, bar is not defined, but foo and baz are. It wouldn't matter if bar took multiple lines.
Comments in compiled files
The compiler can be directed to embed comments in executable files and libraries it generates without affecting their semantics.
#comment -[
I document the source text but will also be embedded in
the output library or executable file.]-
#comment gpl'3'
The latter comment puts the standard GPL license notification in the output file.
Comments as diagnostics
A function f annotated with a crash dump wrapper expressed like this during debugging
my_input_type%C f
is equivalent to just f when changed to this in the production code.
my_input_type%Ck f
Comments as hooks
Compiling with the --depend command line option makes the compiler only scan for the #depend'ed expressions and send them to standard output.
#depend <this,expression> is (parsed)* but {
otherwise,
ignored}
This way, scripts and source management tools can have information passed to them from the programmer by running the compiler instead of re-implementing their own parsers.
VBA
A comment starts with a quote (') and it ends at end of line
' This is a VBA comment
VBScript
A comment starts with a quote (') and it ends at end of line
' This is a VBScript comment
Verbexx
//////////////////////////////////////////////////////////////////////////////////////////////
//
// Line Comments:
// =============
//
@VAR v1 = 10; // Line comments start from the "//" and continue to end of the line.
// (normal code can appear on the same line, before the //)
//
// Line comments can span a complete line, or start in the middle of a line.
///
//// Additional // chars and /* /* /[ ]/ and /] are ignored
//// Line comments can be appear to be nested, since any additional // is ignored.
///
// Note: // can appear in strings without triggering a line comment
// // cannot appear inside an operator (or verbname), since a line comment
// would start
//
/////////////////////////////////////////////////////////////////////////////////////////////
/********************************************************************************************
*
* Block Comments:
* ==============
*
********************************************************************************************/
//*
//* These start with /* and end with the next */ . They cannot be nested, since the first */
//* will end the block comment. For example, the comment, /* /* */ */ would end after the
//* first */. Note that /* is ignored inside a block comment, as are // /[ /] and /].
//*
//* Also note that something like the following will cause trouble in a block comment:
//*
//* /* comments //
//* * more comments // */ (the // does not prevent the */ from ending
//* * (no longer part of the comment) // block comment)
//* */
//*
//* Note: /* can appear in strings without triggering the start of a block comment
//* /* cannot appear inside an operator (or verbname), since a line comment will
//* start, although */ is allowed inside an operator (verbname). Commenting
//* out such a verbname may cause problems.
//*
//* Note: Since string literals are not recognized in block comments, */ appearing
//* in a string literal inside a block comment (perhaps commented-out code)
//* will cause the block comment to end.
//*
//* Note: It is an error to start a block comment and not end it, so that it is still
//* in progresss when the end-of-file is reached.
//*
//* Block comments can appear inside lines of code:
//*
/*1*/@VAR/*2*/v2/*3*/=/*4*/20/*5*/;/*6*/ // a line comment can follow block comments on the
// same line
/[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]
/[] []
/[] Nestable Block Comments: []
[] ======================== []/
[] []/
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]/
//[]
//[] These start with /[ and end with the next matching ]/ . Additional occurrences
//[] of /[ ... ]/ can appear inside a nestable block comment. The nestable block comment
//[] will end only when the nest level reaches 0. Note that /* is ignored inside a nestable
//[] block comment, as are */ // and /].
//[]
//[] Nestable block comments can be used to comment out blocks of code containing line
//[] comments or regular comments, and even balanced and well-formed nestable block comments.
//[]
//[] Note: /[ can appear in strings without triggering the start of a block comment.
//[] However, strings literals are not recognized inside a nestable block comment, so
//[] any appearances of /[ and /] inside a string literal in a nestable block commment
//[] will affect the nest level, and may cause problems.
//[]
//[] Note: It is an error to start a nestable block comment and not end it, so that it is
//[] still in progresss when the end of file is reached.
//[]
//[] Nestable block comments can appear inside lines of code:
//[]
/[1]/@VAR/[2]/v3/[3]/=/[4]/30/[5]/;/[6]/ // a line comment can follow nestable block comments
// on the same line
@SAY v1 v2 v3; // should see: 10 20 30
/]
/=================================================================================================\
| |
| /] starts a block comment that lasts until the end of the current file. Everything after |
| the /] is ignored. |
| |
\=================================================================================================/
Verilog
// Single line commment.
/*
Multiple
line
comment.
*/
VHDL
-- Single line commment in VHDL
Vim Script
All lines starting with " are comments and will be ignored.
In most cases, " will also work after a command (i.e. the rest of the line will be ignored). But some commands like echo
treat the whole line as their argument and thus will raise an error (Missing quote).
let a = 4 " A valid comment
echo "foo" " Not a comment but an argument that misses the closing quote
Visual Basic
In addition to the methods mentioned in BASIC above, it is also somewhat common to effectively comment out code by including the unwanted code inside an #If 0 ... #End If
block. (This works because 0 evaluates to False in VB.) Note, however, that the IDE will complain about actual comments inside an #If 0
block unless it's also commented normally (i.e., using Rem
or '
).
'comment
Rem comment
#If 0
Technically not a comment; the compiler may or may not ignore this, but the
IDE won't. Note the somewhat odd formatting seen here; the IDE will likely
just mark the entire line(s) as errors.
#End If
Visual Basic .NET
Visual Basic .NET uses the "'" symbol or "REM" to mark it's comments. After placing a "'", or "REM", everything in that line will be ignored.
' This is a comment
REM This is also a comment
Dim comment as string ' You can also append comments to statements
Dim comment2 as string REM You can append comments to statements
Visual Objects
// This is a comment
/* This is a comment */
* This is a comment
&& This is a comment
NOTE This is a commen
V (Vlang)
// This is a single line comment. /* This is a multiline comment. /* It can be nested. */ */
Vorpal
# single line comment
Wart
# single-line comment
Wren
// This is a line comment.
/* This is a single line block comment.*/
/* This is
a multi-line
block comment.*/
/* This is/* a nested */block comment.*/
X10
All text included within the ASCII characters “/*” and “*/” is considered a comment and ignored; nested comments are not allowed.
All text from the ASCII characters “//” to the end of line is considered a comment and is ignored.
// This is a single line comment
/*
This comment spans
multiple lines
*/
XLISP
; this is a comment
Xojo
// Comments are denoted by a preceding double slash or or single quote
' and continue to the end of the line. There are no multi-line comment blocks
Dim foo As Integer // Comments can also occupy the ends of code lines
XPL0
Comments are enclosed in backslash characters, but the end of a line always terminates a comment. Consequently there is no multi-line comment. For example:
Text(0, \comment\ "Hello \not a comment\ World!"); \comment
Since backslashes toggle comments on and off, it could be inconvenient to comment out a line of code that contains a comment. For example, two additional backslashes could be used to comment out this line, as shown here:
Text(0, "Hello World"); \comment
\Text(0, "Hello World"); \\comment
However, two backslashes together comment out everything to the end of the line regardless of any backslashes the line might contain. So the first example could be commented out like this:
\\Text(0, \comment\ "Hello \not a comment\ World"); \comment
Conditional compilation can be used to effectively comment out multiple lines of code. For example:
cond false;
Text(0, "Hello World"); \comment
CrLf(0);
cond true;
XQuery
(: This is a XQuery comment :)
XSLT
<!-- Comment syntax is borrowed from XML and HTML. -->
XUL
<!-- Comment syntax is borrowed from XML and HTML. -->
Yacas
Yacas supports C++ style comments:
// This is a single line comment
/*
This comment spans
multiple lines
*/
Z80 Assembly
Note: syntax depends on the assembler software but use of a semicolon is fairly standard. VASM and WinAPE use the semicolon.
ld hl,&8000 ;This is a comment
Zig
// This is a normal comment in Zig
/// This is a documentation comment in Zig (for the following line)
zkl
x=1; // comment ala C++
x=2; # ala scripts
/* ala C, these comments are parsed (also ala C) */
/* can /* be */ nested */
#if 0
also ala C (and parsed)
#endif
#<<<#
"here" comment, unparsed
#<<<#
Zoea
program comments # this program does nothing
# zoea supports single line comments starting with a '#' char
/*
zoea also supports
multi line
comments
*/
Zoea Visual
zonnon
(* this is a comment *)
(*
and this is a
multiline comment
(* with a nested comment *)
*)
- Programming Tasks
- Basic language learning
- Initialization
- 11l
- 360 Assembly
- 4D
- 4ME
- 6502 Assembly
- 68000 Assembly
- 8086 Assembly
- AArch64 Assembly
- ACL2
- Action!
- ActionScript
- Ada
- Agena
- ALGOL 60
- ALGOL 68
- ALGOL-M
- ALGOL W
- AmigaE
- AngelScript
- AntLang
- Apex
- APL
- AppleScript
- Arendelle
- ARM Assembly
- Arturo
- Asymptote
- AutoHotkey
- AutoIt
- AWK
- Axe
- Babel
- BASIC
- Applesoft BASIC
- BaCon
- BASIC256
- Chipmunk Basic
- IS-BASIC
- Minimal BASIC
- MSX Basic
- Quite BASIC
- True BASIC
- XBasic
- Yabasic
- Batch File
- BBC BASIC
- Bc
- Beef
- Befunge
- Binary Lambda Calculus
- Blast
- BQN
- Bracmat
- Brainf***
- Brat
- Bruijn
- Brlcad
- Burlesque
- C
- C sharp
- C++
- Chapel
- Chef
- ChucK
- Clean
- Clojure
- CMake
- COBOL
- CoffeeScript
- ColdFusion
- Common Lisp
- Component Pascal
- Crystal
- D
- Dart
- Dc
- Delphi
- Deluge
- Dragon
- DWScript
- Dyalect
- Dylan
- Déjà Vu
- E
- EasyLang
- EchoLisp
- ECL
- Ecstasy
- Ed
- EDSAC order code
- EGL
- Eiffel
- Ela
- Elena
- Elixir
- Elm
- Emacs Lisp
- EMal
- Erlang
- ERRE
- Euphoria
- F Sharp
- Factor
- Falcon
- FALSE
- Fancy
- Fennel
- Fermat
- Fish
- Forth
- Fortran
- FreeBASIC
- Frink
- Futhark
- FutureBasic
- FUZE BASIC
- Gambas
- GAP
- Gecho
- Gema
- Genie
- GML
- Gnuplot
- Go
- Golfscript
- Gri
- Groovy
- GW-BASIC
- Haskell
- Haxe
- HicEst
- Hope
- HTML
- Icon
- Unicon
- IDL
- Inform 7
- Insitux
- Intercal
- Io
- Isabelle
- J
- Java
- JavaScript
- JCL
- Joy
- Jq
- Jsish
- Julia
- K
- KonsolScript
- Kotlin
- Lambdatalk
- LabVIEW
- Lang
- Lang5
- Langur
- Lasso
- LaTeX
- Liberty BASIC
- Lily
- LilyPond
- Lingo
- LiveCode
- Logo
- Logtalk
- LOLCODE
- LotusScript
- LSE
- LSE64
- Lua
- M2000 Interpreter
- M4
- Maple
- Mathematica
- Wolfram Language
- MATLAB
- Maxima
- MAXScript
- MBS
- MEL
- Metafont
- Microsoft Small Basic
- Min
- MiniScript
- Mirah
- MIPS Assembly
- MIRC Scripting Language
- Modula-2
- Modula-3
- Monte
- MontiLang
- MOO
- Nanoquery
- NATURAL
- Neko
- Nemerle
- NESL
- NetRexx
- NewLISP
- Nim
- Nix
- NSIS
- Oberon-2
- Objeck
- Objective-C
- OCaml
- Octave
- Oforth
- OoRexx
- Openscad
- OxygenBasic
- Oz
- PARI/GP
- Pascal
- PascalABC.NET
- PASM
- Peloton
- Perl
- Phix
- Phix/basics
- PHP
- Picat
- PicoLisp
- Pike
- PL/I
- PL/SQL
- Plain English
- PlainTeX
- Pop11
- PostScript
- PowerShell
- Processing
- Processing Python mode
- ProDOS
- ProgressBASIC
- Prolog
- PureBasic
- Python
- Quackery
- QB64
- R
- Racket
- Raku
- Rapira
- Raven
- REBOL
- Relation
- Retro
- REXX
- Ring
- RLaB
- Robotic
- Rockstar
- RPL
- Ruby
- Run BASIC
- Rust
- SAS
- Sather
- S-BASIC
- Scala
- Scheme
- Scilab
- Sed
- Seed7
- SenseTalk
- Set lang
- SETL
- Sidef
- Simula
- Slate
- Smalltalk
- Smart BASIC
- SNOBOL4
- SNUSP
- SPL
- SQL
- SQL PL
- Squirrel
- SSEM
- Standard ML
- Stata
- SuperTalk
- Swift
- Symsyn
- Tcl
- Tern
- TI-83 BASIC
- TI-89 BASIC
- Tiny BASIC
- Toka
- TorqueScript
- TPP
- Transd
- TUSCRIPT
- TXR
- UNIX Shell
- C Shell
- Es
- Unlambda
- Ursa
- Ursala
- VBA
- VBScript
- Verbexx
- Verilog
- VHDL
- Vim Script
- Visual Basic
- Visual Basic .NET
- Visual Objects
- V (Vlang)
- Vorpal
- Wart
- Wren
- X10
- XLISP
- Xojo
- XPL0
- XQuery
- XSLT
- XUL
- Yacas
- Z80 Assembly
- Zig
- Zkl
- Zoea
- Zoea Visual
- Zonnon
- Computer/zero Assembly/Omit
- Pages with too many expensive parser function calls