Comment (computer programming): Difference between revisions

Content deleted Content added
Examples: Merge Ada and Haskell into group section
 
(30 intermediate revisions by 10 users not shown)
Line 4:
[[File:CodeCmmt002.svg|thumb|right|300px|[[Java (programming language)|Java]] source code with block comments in <span style="color:#f00;">red</span>, line comments in <span style="color:#0e850e;">green</span> and program code in <span style="color:#00f;"> blue</span>.]]
 
In [[computer programming]], a '''comment''' is text embedded in [[source code]] that a translator ([[compiler]] or [[interpreter (computing)|interpreter]]) ignores. Generally, a comment is an [[annotation]] intended to make the code easier for a [[programmer]] to understand {{endash}} often explaining an aspect that is not readily apparent in the program (non-comment) code.<ref name="PennyGrubb000">{{cite book | last = Penny Grubb | first = Armstrong Takang | title = Software Maintenance: Concepts and Practice | publisher = World Scientific | year = 2003 | isbn = 978-981-238-426-3 | pages = 7, plese start120–121}}</ref> For this article, ''comment'' refers to the same concept in a [[programming languageslanguage]], [[markup language]]s, [[configuration file]]s and any similar context.<ref>{{cite book | last = Ganguli | first = Madhushree | title = Making Use of Jsp | publisher = Wiley | ___location = New York | year = 2002 | isbn = 978-0-471-21974-3 }}, {{cite book | last = Hewitt | first = Eben | title = Java for Coldfusion Developers | publisher = Pearson Education | ___location = Upper Saddle River | year = 2003 | isbn = 978-0-13-046180-3}}</ref> Some [[development tool]]s, other than a source code translator, do [[parse]] comments to provide capabilities such as [[API]] [[documentation generator|document generation]], [[static analysis]], and [[version control]] integration. The [[comparison of programming languages (syntax)#Comments|syntax of comments]] varies by programming language yet there are repeating patterns in the syntax among languages as well as similar aspects related to comment content.
 
The flexibility supported by comments allows for a wide degree of content style variability. To promote uniformity, style conventions are commonly part of a [[programming style]] guide. But, [[best practice]]s are disputed and contradictory.<ref name="Dietrich000">{{cite book
Comments can be processed by some [[development tools]] to provide capabilites such as [[API]] [[documentation generator|document generation]], [[static analysis]], and [[version control]] integration.
 
The [[comparison of programming languages (syntax)#Comments|syntax of comments]] varies considerably by [[programming language]]. But generally, the flexibility supported by comments allows for a wide degree of style variability. To promote uniformity, conventions for their style are commonly part of a [[programming style]] guide. But, [[best practice]]s are disputed and contradictory.<ref name="Dietrich000">{{cite book
| last = W. R.
| first = Dietrich
Line 28 ⟶ 26:
Support for code comments is defined by each programming language. The features differ by language, but there are several common attributes that apply throughout.
 
Most languages support multi-line '''block''' (a.k.a. stream) and/or single '''line''' comments. A '''block comment''' blockis or[[delimiter#Bracket sequencedelimiters|delimited]] ofwith linetext commentsthat located nearmarks the topstart ofand anend associatedof programmingcomment topic,text. suchIt ascan beforespan amultiple symbol declarationlines or atoccupy theany toppart of a file,line. isSome calledlanguages aallow ''prologueblock comment''.comments Ato commentbe thatrecursively isnested on onlyinside one lineanother, usuallybut afterothers programdo code, is called an ''inline comment''not.<ref name="JBDixit000Higham000">{{cite book | last = Dixit | first = J.B. | title = Computer Fundamentals and Programming in C | publisher = Laxmi Publications | year = 2003 | isbn = 978-81-7008-882-0 }}</ref>
 
A '''block comment''' is [[delimiter#Bracket delimiters|delimited]] with text that marks the start and end of the block. It can span multiple lines or occupy any part of a line. Some languages (such as [[MATLAB]]) allow block comments to be recursively nested inside one another, but others (such as [[Java (programming language)|Java]]) do not.<ref name="Higham000">{{cite book
| title = MATLAB Guide
| first = Desmond
Line 50 ⟶ 46:
| access-date = 2007-07-24
| date = 2000-03-04
}}</ref> A '''line comment''' ends at the end of the text line. In modern languages, a line comment starts with a delimiter but some older languages designate a column at which subsequent text is considered comment.<ref name="javadude000" /> Many languages support both block and line comments {{endash}} using different delimiters for each. For example, [[C (programming language)|C]], [[C++]] and their many derivatives support block comments delimited by <code>/*</code> and <code>*/</code> and line comments delimited by <code>//</code>. Other languages support only one type of comment.<ref name="javadude000" />
}}</ref>
 
Comments can also be classified as either prologue or inline based on their position and content relative to program code. A '''prologue comment''' is a comment (or group of related comments) located near the top of an associated programming topic, such as before a symbol declaration or at the top of a file. An '''inline comment''' is a comment that is located on the same line as and to the right of program code to which is refers.<ref name="JBDixit000">{{cite book | last = Dixit | first = J.B. | title = Computer Fundamentals and Programming in C | publisher = Laxmi Publications | year = 2003 | isbn = 978-81-7008-882-0 }}</ref> Both prologue and inline comments can be represented as either line or block comments. For example:
In modern languages, a '''line comment''' starts with a delimiter and continues until the end of the line. Some older languages designated a column at which subsequent text is considered comment text.<ref name="javadude000" />
 
<syntaxhighlight lang="c">
Most modern languages support both block and line comments {{endash}} using different delimiters for each. For example, [[C (programming language)|C]], [[C++]] and their many derivatives support block comments delimited by <code>/*</code> and <code>*/</code> and line comments delimited by <code>//</code>. Other languages support only one type of comment.<ref name="javadude000" />
/*
* prologue block comment; if is about foo()
*/
bool foo() {
return true; /* inline block comment; if is about this return */
}
 
//
// prologue line comment; if is about bar()
//
bool bar() {
return false; // inline line comment; if is about this return
}
</syntaxhighlight>
 
==Examples of use==
Line 116 ⟶ 126:
Comments can store [[metadata]] about the code. Common metadata includes the name of the original author and subsequent maintainers, dates when first written and modified, link to development and user documentation, and legal information such as [[copyright]] and [[software license]].
 
Some [[programming tools]] write metadata into the code as comments.<ref>See e.g., {{cite book |last=Wynne-Powell |first=Rod |year=2008 |title=Mac OS X for Photographers: Optimized Image Workflow for the Mac User |page=243 |publisher=Focal Press |___location=Oxford |isbn=978-0-240-52027-8 |url=https://archive.org/details/macosxforphotogr0000wynn}}</ref> For example, a [[version control]] tool might write metadata such as author, date and version number into each file when it's commitedcommitted to the repository.<ref>See e.g., {{cite book |last=Berlin |first=Daniel |year=2006 |title=Practical Subversion, Second Edition |page=168 |publisher=APress |___location=Berkeley |isbn=978-1-59059-753-8}}</ref>
 
=== Integrate with development tools ===
Line 135 ⟶ 145:
| publisher=Cambridge University Press
| isbn=978-1-397-80521-8
}}</ref> Examples include [[Javadoc]], [[Ddoc]], [[Doxygen]], [[Visual Expert]] and [[PHPDoc]]. Forms of [[docstring]] are supported by [[Python (programming language)|Python]], [[Lisp (programming language)|Lisp]], [[Elixir (programming language)|Elixir]], and [[Clojure]].<ref>[https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/defn Function definition with docstring in Clojure]</ref> [[C Sharp (programming language)|C#]], [[F Sharp (programming language)|F#]] and [[Visual Basic .NET]] implement a similar feature called "XML Comments" which are read by [[IntelliSense]] from the compiled [[.NET]] assembly.<ref>{{cite book|last=Murach|title=C# 2005|page=56}}</ref>
 
=== Visualization ===
Line 183 ⟶ 193:
=== Extend language syntax ===
 
Occasionally, code that is formatted as a comment is overloaded to convey additional information to the translator, such as [[conditional comment]]scomments. As such, syntax that generally indicates a comment can actually represent program code; not comment code. Such syntax may be a practical way to maintain compatibility while adding additional functionality, but some regard such a solution as a [[kludge]].<ref>[[c2: HotComments]]</ref>
 
Other examples include interpreter [[Directive (programming)|directives]]:
Line 282 ⟶ 292:
 
<syntaxhighlight lang="c">
/***************************\**
* *
* This is the comment body. *
* *
\ *****************************/
</syntaxhighlight>
 
Line 323 ⟶ 333:
 
==Tags==
Programmers often use one of select words {{endash}} also konwnknown as [[tag (metadata)|tags]], codetags<ref>[https://www.python.org/dev/peps/pep-0350/#what-are-codetags "PEP 0350 – Codetags"], Python Software Foundation</ref><ref>[https://medium.com/@eido.askayo/never-forget-anything-before-after-and-while-coding-98d187ae4cf1 "Never Forget Anything Before, After and While Coding"], Using "codetag" comments as productive remainders</ref> and tokens<ref>[https://msdn.microsoft.com/en-us/library/txtwdysk.aspx#tokenscomments "Using the Task List"], msdn.microsoft.com</ref> {{endash}} to categorize the information in a comment. Programmers may leverage these tags by searching for them via a [[text editor]] or [[grep]]. Some editors [[Syntax highlighting|highlight]] comment text based on tags.
 
Commonly used tags include:
Line 344 ⟶ 354:
 
===Curly brace languages===
Many of the [[curly brace language]]s such as C, C++ and their many derivatives delimit a line comment with {{code|//}} and a block comment with {{code|/*}} and {{code|*/}}. Originally, C lacked the line comment, but it was added in [[C99]]. Notable languages include: C, C++, [[C# (programming language)|C#]], [[D (programming language)|D]], [[Java (programming language)|Java]], [[JavascriptJavaScript]] and [[Swift (programming language)|Swift]]. For example:
 
<syntaxhighlight lang="c">
Line 357 ⟶ 367:
</syntaxhighlight>
 
Some languages, including D and Swift, allow blocks to be nested while other do not, including C and C++.

An example of nested blocks in SwiftD:
 
<syntaxhighlight lang="d">
// line comment
/*
block comment
*/
/+ start of outer block
/+ inner block +/
end of outer block +/
</syntaxhighlight>
 
An example of nested blocks in Swift:
 
<syntaxhighlight lang="swift">
Line 457 ⟶ 481:
</syntaxhighlight>
 
====DoubleBrowser dash=markup===
 
Markup languages in general vary in comment syntax, but some of the notable internet markup formats such as [[HTML]] and [[XML]] delimit a block comment with <code>&lt;!--</code> and <code>--&gt;</code> and provide no line comment support. An example in XML:
A relatively loose collection of languages use <code>--</code> for a single line comment. Notable languages include: [[Ada (programming language)|Ada]] and [[Haskell]]. An example in Ada:
 
<syntaxhighlight lang="xml">
<!-- select the context here -->
<param name="context" value="public" />
</syntaxhighlight>
 
For compatibility with [[SGML]], double-hyphen (--) is not allowed inside comments.
 
[[ColdFusion]] provides syntax similar to the [[HTML comment]], but uses three dashes instead of two. CodeFusion allows for nested block comments.
 
===Double dash===
 
A relatively loose collection of languages use <code>--</code> for a single line comment. Notable languages include: [[Ada (programming language)|Ada]], [[Eiffel (programming language)|Eiffel]], [[Haskell (programming language)|Haskell]], [[Lua (programming language)|Lua]], [[SQL]] and [[VHDL]]. Block comment support varies. An example in Ada:
 
<syntaxhighlight lang="ada">
Line 511 ⟶ 548:
</syntaxhighlight>
 
===By=Block languagein Lua====
Lua supports block comments delimited by <code>--[[</code> and <code>]]</code><ref>{{Cite web|url=http://www.lua.org/pil/1.3.html|title=Programming in Lua 1.3|website=www.Lua.org|access-date=2017-11-08}}</ref> For example:
 
<syntaxhighlight lang="lua">
--[[A multi-line
long comment
]]
</syntaxhighlight>
 
==== Block in SQL ====
In some variants of SQL, the curly brace language block comment (<code>/**/</code>) is supported. Variants include: [[Transact-SQL]], [[MySQL]], [[SQLite]], [[PostgreSQL]], and [[Oracle Database|Oracle]].<ref name="MSSQL">{{cite book
| title = Microsoft SQL Server 7
| first = Ronald R.
| last = Talmage
| publisher = Prima Publishing
| year = 1999
| isbn = 978-0-7615-1389-6
| url = https://archive.org/details/microsoftsqlserv00talm
}}</ref><ref name="MySQL">{{cite web | url=https://dev.mysql.com/doc/refman/8.0/en/comments.html | title=MySQL 8.0 Reference Manual | publisher=Oracle Corporation | access-date=January 2, 2020}}</ref><ref name="SQLite">{{cite web | url=https://www.sqlite.org/lang_comment.html | title=SQL As Understood By SQLite | publisher=SQLite Consortium | access-date=January 2, 2020}}</ref><ref name="PostgreSQL">{{cite web | url=https://www.postgresql.org/docs/10/sql-syntax-lexical.html#SQL-SYNTAX-COMMENTS | title=PostgreSQL 10.11 Documentation | publisher=The PostgreSQL Global Development Group | access-date=January 2, 2020}}</ref><ref name="Oracle">{{cite web | url=https://docs.oracle.com/cd/B13789_01/server.101/b10759/sql_elements006.htm | title=Oracle® Database SQL Reference | publisher=Oracle Corporation | access-date=January 2, 2020}}</ref>
 
MySQL also supports a line comment delimited by <code>#</code>.
 
===Less common syntax===
 
====APL====
 
[[APL (programming language)|APL]] uses <code>⍝</code> ("lamp") for a line comment. For example:
 
<syntaxhighlight lang="apl">
Line 531 ⟶ 590:
 
<syntaxhighlight lang="AppleScript">
# line comment (in later versions)
(*
This program displays a greeting.
Line 552 ⟶ 612:
</syntaxhighlight>
 
In later variations, including [[Quick Basic]], [[Q Basic]], [[Visual Basic]] (VB), [[Visual Basic .NET|VB.NET]], [[VB ScriptVBScript]], [[FreeBASIC]] and [[Gambas]], a line comment is delimteddelimited with apostrophe<code>'</code> ('apostrophe). An example in Visual Basic VB.NET:
 
<syntaxhighlight lang="vbnet">
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' Thenew followingstyle codeline is executed when the usercomment
'rem clicksold thestyle buttonline incomment thestill program's window.supported
MessageBox.Show("Hello, World") ' show dialog with a greeting
rem comments still exist.
 
MessageBox.Show("Hello, World") 'Show a pop-up window with a greeting
End Sub
End Class
Line 586 ⟶ 644:
</syntaxhighlight>
 
====ColdFusionFortran====
The following fixed-form [[Fortran]] code fragment shows that comment syntax is column-oriented. A letter <code>C</code> in the first column causes the entire line to be treated as a comment. In [[Fortran 77]], an asterisk in column 1 also indicates a comment.
[[ColdFusion]] uses comments similar to [[HTML comment]]s, but instead of two dashes, it uses three. These comments are caught by the ColdFusion engine and not printed to the browser.
 
Such comments are nestable.
 
<syntaxhighlight lang="cfm">
<!--- This prints "Hello World" to the browser.
<!--- This is a comment used inside the first one.
--->
--->
<cfoutput>
Hello World<br />
</cfoutput>
</syntaxhighlight>
 
====D====
[[D (programming language)|D]] uses C++-style comments, as well as nestable D-style multiline comments, which start with '/+' and end with '+/'.
 
<syntaxhighlight lang="d">
// This is a single-line comment.
/* This is a multiline comment.
 
*/
/+ This is a
/+ nested +/
comment +/
</syntaxhighlight>
 
====Fortran IV====
This [[Fortran IV]] code fragment demonstrates how comments are used in that language, which is very column-oriented. A letter "C" in column 1 causes the entire line to be treated as a comment.
 
<syntaxhighlight lang="fortranfixed">
C
C Lines that beginbeginning with 'C' (in the first or(a.k.a. 'comment') column) are comments
C
WRITE (6,610)
Line 626 ⟶ 656:
</syntaxhighlight>
 
The following [[Fortran|Fortran 90]] code fragment shows a more modern line comment syntax; text following <code>!</code>.
Note that the columns of a line are otherwise treated as four fields: 1 to 5 is the label field, 6 causes the line to be taken as a continuation of the previous statement; and declarations and statements go in 7 to 72.
 
====Fortran 90====
This [[Fortran]] code fragment demonstrates how comments are used in that language, with the comments themselves describing the basic formatting rules.
<syntaxhighlight lang="Fortran">
! A comment
!* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
!* All characters after an exclamation mark are considered as comments *
!* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
program comment_test
print '(A)', 'Hello world' ! Fortranalso 90a introduced the option for inline comments.comment
end program
</syntaxhighlight>
 
Free-form Fortran, also introduced with Fortran 90, only supports this latter style of comment.
====Lua====
[[Lua (programming language)|Lua]] uses double-hyphens, <code>--</code>, for single line comments in a similar way to [[Ada (programming language)|Ada]], [[Eiffel (programming language)|Eiffel]], [[Haskell (programming language)|Haskell]], [[SQL]] and [[VHDL]] languages. Lua also has block comments, which start with <code>--[[</code> and run until a closing <code>]]</code> For example:
 
Although not a part of the Fortran Standard, many Fortran compilers offer an optional C-like [[preprocessor]] pass. This can be used to provide block comments:
<syntaxhighlight lang="lua">
--[[A multi-line
long comment
]]
print(20) -- print the result
</syntaxhighlight>
 
<syntaxhighlight lang="Fortran">
A common technique to comment out a segment of code,<ref>{{Cite web|url=http://www.lua.org/pil/1.3.html|title=Programming in Lua 1.3|website=www.Lua.org|access-date=2017-11-08}}</ref> is to enclose the code between <code>--[[</code> and
#if 0
<code>--]]</code>, as below:
This is a block comment spanning
 
multiple lines.
<syntaxhighlight lang="lua">
#endif
--[[
program comment_test
print(10)
print '(A)', 'Hello world' ! also a comment
--]]
end program
-- no action (commented out)
</syntaxhighlight>
 
In this case, it's possible to enable the code for use (uncomment-out) by adding a single hyphen to the first line:
 
<syntaxhighlight lang="lua">
---[[
print(10)
--]]
--> 10
</syntaxhighlight>
 
The <code>--[[</code> in the first line starts a long comment, and the two hyphens in the last line
are still inside that comment. In the second example, the sequence <code>---[[</code> starts an ordinary, single-line
comment, so that the first and the last lines become independent comments. In this case, the <code>print</code> is
outside comments. In this case, the last line becomes an independent comment, as it starts with <code>--</code>.
 
====MATLAB====
Line 694 ⟶ 700:
 
====Nim====
[[Nim (programming language)|Nim]] usesdelimits thea 'line comment with <code>#'</code> characterand forblock inlinecomments with <code>#[</code> and <code>]#</code>. Block comments can be nested.
Multi-line block comments are opened with '#[' and closed with ']#'.
Multi-line block comments can be nested.
 
Nim also has documentation comments that use mixed [[Markdown]] and [[ReStructuredText]] markups.
TheA inlineline documentation commentscomment useuses '##' and multi-linea block documentation commentscomment are opened withuses '##[' and closed with ']##'.
The compiler can generate [[HTML]], [[LaTeX]] and [[JSON]] documentation from the documentation comments.
Documentation comments are part of the [[abstract syntax tree]] and can be extracted using macros.<ref>[https://nim-lang.github.io/Nim/macros.html#extractDocCommentsAndRunnables%2CNimNode macros.extractDocCommentsAndRunnables]</ref>
Line 718 ⟶ 722:
 
====OCaml====
[[OCaml]] supports nestable comments. For exmapleexample:
<syntaxhighlight lang="ocaml">
codeLine(* comment level 1(*comment level 2*)*)
Line 725 ⟶ 729:
====Pascal, Delphi====
 
In [[Pascal (programming language)|Pascal]] and [[Delphi (software)|Delphi]], a block comment is delimited by <code>{</code> and <code>}</code>, and as an alternative for computers that do not support these characters, <code>(*</code> and <code>*)</code> are also supported. A line comment is delimited by <code>\\</code>.<ref>{{cite book|author=Kathleen Jensen, Niklaus Wirth|year=1985|title=Pascal User Manual and Report|publisher=Springer-Verlag|isbn=0-387-96048-1}}</ref> In [[Niklaus Wirth]]'s more modern family of languages (including [[Modula-2]] and [[Oberon (programming language)|Oberon]]), comments are delimited by <code>(*</code> and <code>*)</code>.<ref>{{cite book|author=Niklaus Wirth|year=1983|title=Programming in Modula-2|publisher=Springer-Verlag|isbn=0-387-15078-1}}</ref><ref>*{{cite book|author=Martin Reiser, Niklaus Wirth|year=1992|title=Programming in Oberon|publisher=Addison-Wesley|isbn=0-201-56543-9}}</ref> Comments can be nested. For example:
In [[Pascal (programming language)|Pascal]] and [[Delphi (software)|Delphi]], comments are delimited by '{&nbsp;...&nbsp;}'. Comment lines can also start with '\\' .
As an alternative, for computers that do not support these characters, '(*&nbsp;...&nbsp;*)' are allowed.<ref>{{cite book|author=Kathleen Jensen, Niklaus Wirth|year=1985|title=Pascal User Manual and Report|publisher=Springer-Verlag|isbn=0-387-96048-1}}</ref> In [[Niklaus Wirth]]'s more modern family of languages (including [[Modula-2]] and [[Oberon (programming language)|Oberon]]), comments are delimited by '(*&nbsp;...&nbsp;*)'.<ref>{{cite book|author=Niklaus Wirth|year=1983|title=Programming in Modula-2|publisher=Springer-Verlag|isbn=0-387-15078-1}}</ref><ref>*{{cite book|author=Martin Reiser, Niklaus Wirth|year=1992|title=Programming in Oberon|publisher=Addison-Wesley|isbn=0-201-56543-9}}</ref> Comments can be nested. // can be included in a {} and {} can be included in a (**). For example:
 
<syntaxhighlight lang="pascal">
Line 736 ⟶ 739:
 
====PHP====
Comments in [[PHP]] can be either incurly C++brace style (both inlineline and block), or useline hashesdelimited with <code>#</code>l. [[PHPDoc]]Blocks iscannot be nested. Starting in PHP 8, a style<code>#</code> adaptedonly frommeans Javadoccomment andif isit's anot commonimmediately standardfollowed forby documenting<code>[</code>. PHPOtherwise, it delimits an attribute, which continues till the next <code>]</code>. For example:
 
Starting in PHP 8, the # sign can only mean a comment if it's not immediately followed by '['. Otherwise, it will mean a function attribute, which runs until ']':
 
<syntaxhighlight lang="php">
/**
* This class contains a sample documentation.
*
* @author Unknown
*/
Line 749:
class MyAttribute {
const VALUE = 'value';
// ThisC++ isstyle an inlineline comment. It starts with '//', like in C++.
private $value;
# Thisscript is a Unix-style inlineline comment, which starts with '#'.
public function __construct($value = null) {
$this->value = $value;
}
/*
This is a multiline comment.
 
These comments cannot be nested.
*/
 
}
</syntaxhighlight>
 
==== SQL ====
Standard comments in SQL are in single-line-only form, using two dashes:
<syntaxhighlight lang="sql">
-- This is a single line comment
-- followed by a second line
SELECT COUNT(*)
FROM Authors
WHERE Authors.name = 'Smith'; -- Note: we only want 'smith'
-- this comment appears after SQL code
</syntaxhighlight>
Alternatively, a comment format syntax identical to the "block comment" style used in the syntax for C and Java is supported by [[Transact-SQL]], [[MySQL]], [[SQLite]], [[PostgreSQL]], and [[Oracle Database|Oracle]].<ref name="MSSQL">{{cite book
| title = Microsoft SQL Server 7
| first = Ronald R.
| last = Talmage
| publisher = Prima Publishing
| year = 1999
| isbn = 978-0-7615-1389-6
| url = https://archive.org/details/microsoftsqlserv00talm
}}</ref><ref name="MySQL">{{cite web | url=https://dev.mysql.com/doc/refman/8.0/en/comments.html | title=MySQL 8.0 Reference Manual | publisher=Oracle Corporation | access-date=January 2, 2020}}</ref><ref name="SQLite">{{cite web | url=https://www.sqlite.org/lang_comment.html | title=SQL As Understood By SQLite | publisher=SQLite Consortium | access-date=January 2, 2020}}</ref><ref name="PostgreSQL">{{cite web | url=https://www.postgresql.org/docs/10/sql-syntax-lexical.html#SQL-SYNTAX-COMMENTS | title=PostgreSQL 10.11 Documentation | publisher=The PostgreSQL Global Development Group | access-date=January 2, 2020}}</ref><ref name="Oracle">{{cite web | url=https://docs.oracle.com/cd/B13789_01/server.101/b10759/sql_elements006.htm | title=Oracle® Database SQL Reference | publisher=Oracle Corporation | access-date=January 2, 2020}}</ref>
 
MySQL also supports comments from the hash (#) character to the end of the line.
 
====XML and HTML====
A block comment in [[XML]] and [[HTML]] is delimited by
<code>&lt;!--</code> and <code>--&gt;</code>. Line comment is not supported. For example,
 
<syntaxhighlight lang="xml">
<!-- select the context here -->
<param name="context" value="public" />
</syntaxhighlight>
 
For compatibility with [[SGML]], double-hyphen (--) is not allowed inside comments.
 
==Security issues==
Line 808 ⟶ 769:
 
==See also==
* [[Comparison of programming languages (syntax)#Comments]]
* [[Docstring]], a specific type of comment that is parsed and retained throughout the runtime of the program.
* [[Shebang (Unix)|Shebang]], the use of ''#!'' as an interpreter directive in scripts on Unix-like systems
* [[HTML comment tag]]
* [[Literate programming]], alternative documentation [[programming paradigm|paradigm]]
* [[Comparison of programming languages (syntax)#Comments|Syntax of comments]] in various programming languages
* [[COMMENT (CONFIG.SYS directive)]]
* [[REM (CONFIG.SYS directive)]]
 
==Notes and references==