Comment

From IFWiki
Jump to: navigation, search

Comments are notes within source code that remind programmers what their code is doing or why they wrote it the way they did. Although it is often legal to have comments anywhere that whitespace is legal, in practice, comments usually are only inserted either on their own lines (above the code they're commenting on) or at the end of a line of code (to comment on that particular line). Comments have no effect whatsoever on the compiled program; players never see these comments within the game itself.

Comments are marked in the code with one or two special characters at the beginning of a comment, and sometimes with one or two special characters to mark the end of a comment. When the format of a comment does not require special end-characters, the end of the line serves as the end of the comment.

Comments usually cannot be nested. It's usually an error to try to put one comment inside another comment.

Commenting can also be used to "comment out" bits of code without deleting it from the source file. This can be a useful technique to hide temporary code, or to pare down code when trying to locate a programming bug.

Code Compare

Alan 2

-- This is a comment in Alan.
-- There is no multi-line comment format in Alan.

Hugo

! This is a single-line comment in Hugo.

!\
  And this is a multi-line comment
  which goes across more than one line.
\!

Inform 6

! This is a comment in Inform 6.
! There is no multi-line comment format in Inform 6.

Inform 7

[ This is a comment in Inform 7. ]

[ And this is a multi-line comment
  which goes across more than one line. ]

[* This type of comment turns into a footnote. ]

TADS 2 and TADS 3

// This is a single-line comment in TADS.

/*
  And this is a multi-line comment
  Which goes across more than one line.
*/