Comments
Comments are used to annotate and document code.
Line comments
Line comments begin with //
and extend to the end of the line.
// This is a line comment.
let x = 5 // Comments can appear after code.
Documentation comments
Documentation comments begin with ///
and extend to the end of the line.
Documentation comments are used to automatically create documentation from the
source code. Documentation comments can use Markdown.
/// A rational number is a fractional value represented as the ratio of
/// two integers. The `num` is the numerator (i.e., top of the fraction)
/// and the `denom` is the denominator (i.e., bottom of the fraction).
///
/// # Invariants
///
/// - `denom > 0`.
/// - `num` and `denom` must be stored in simplest terms with all common
/// factors removed. For example, `Rational(10, 4)` is not allowed and
/// should be `Rational(5, 2)` with the common factor of 2 removed.
type Rational(num: Int, denom: Int)
Needs specification
The rules and semantics of Markdown in documentation comments are currently unspecified.
Shebang comments
The shebang comment is a special comment that may only appear as the very first text in a source file.
#!/usr/bin/env fuyu
import std/io
def main() {
io::println("hello")
}