Comments

Line Comments

tape
// Everything after // is ignored until end of line
let x: i64 = 42;  // inline comment

Block Comments

tape
/* Block comments can span
   multiple lines */

let y: i64 = /* inline block comment */ 10;

Nested Block Comments

Block comments nest. You can comment out code that already contains block comments:

tape
/* Commenting out this section:
let settings = WindowSettings {
    width: 640;   /* half-size */
    height: 480;
};
*/

Each /* opens a new nesting level, each */ closes one level. The comment ends when all levels are closed.

tape
/* level 1
   /* level 2
      /* level 3 */
   */
*/

This avoids the common C/C++ problem where an inner */ prematurely closes an outer block comment.

Notes

  • Comments are stripped by the scanner and have no effect on compilation
  • There is no doc-comment syntax (/// or /** */) — documentation lives in external files
  • Unterminated block comments (missing closing */) are a compile error

Last modified: