Comments & Documentation

Documenting your code is one of the best ways to manage complexity and collaborate with others. Conjure only supports single line comments, which start with // and continue to the end of the line. Any text following // is ignored by the compiler.

// This is a comment

// This is a set of multiple comments that are
// grouped together to form a larger comment block.

Documentation Comments

Any comments that immediately precede a symbol declaration (like a function or variable) are treated as documentation comments. These comments are extracted and served by intellisense and documentation generation tools.

// Returns the sum of two integers. This function does
// not perform overflow checking.
func add(x i32, y i32) i32 {
	return x + y
}

Region Comments

You can split large files into manageable sections using region comments. These are any comment that contain the pattern of three or more dashes (---). A region comment starts a new section, and the next region comment ends it.

The content between region comments is considered part of that section. Regions are “foldable” in editors that support it, allowing you to collapse and expand sections of code for better readability. Region comments do not currently support nesting.

// --- Section 1 ---
var x i32 = 10

// --- Section 2 ---
var y i32 = 20
var z i32 = x + y

TODO Comments

You can mark places in your code that need further work or attention using TODO comments. These comments start with // TODO: followed by a description of what needs to be done. Many IDEs and text editors can recognize these comments and provide a list of TODOs in your project.

// TODO: Implement error handling
func divide(x i32, y i32) i32 {
	return x / y
}

TODO comments written as !TODO will prevent release builds from completing, reminding you to address them before shipping your code.

// !TODO: Implement error handling
func divide(x i32, y i32) i32 {
	return x / y
}