Sign in Join
Wiki copytemporary

Comments

Deutsch · English · Français · Italiano · Suomi · Русский

Go to: Reserved words | Operators

Comments are human-readable notes or other kinds of annotations to support understanding of code. They are not interpreted by the compiler and ignored when building your program.

Block comments

{

}

Block comments are delimited by the characters { }\

(*

*)

or by the bigrams (* *). The latter is a relict from times where computer keyboards did not necessarily have curly braces. It is not wrong to use the bigrams, but they are at large superseded by the use of curly braces. There is one place where the (* and *) bigrams can be useful. if you are testing code and want to "dike out" or disable certain sections by marking them as inoperative, the pieces can be surrounded by these bigrams, and it will not matter if there are and } comments inside of them.

Example:

pascal
{ public declarations }

In Pascal block comments can be nested. However, nested block comment delimiters have to match: If a block comment starts with an opening curly brace, it can not be closed by asterisk-closing-parenthesis but has to be closed by another closing curly brace.

There is a special class of comment, either beginning {$ or (*$. This indicates the start of a compiler directive, a special instruction to the ompiler about the program, but it does not actually generate instructions to be executed.

Line comments

Line comments or inline comments start with comment delimiter // and continue until the end of the line. Example:

delphi
// This is a stupid comment

Comments as declaration hints in Lazarus IDE

The Lazarus IDE can display tooltip hints when mouseovering identifiers. You can control this in Options > Editor > Completion and Hints.

The hint shows the function or variable definition, but can also include custom descriptive text taken from comment lines directly above the declaration.

Best practice for good comments

Mentioning some general tips for writing “good” comments may not be left out here, too:

See also


From the Free Pascal wiki, page "Comments", as it stood on 2022-08-06 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 2, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.