Comments

A comment is text to explain how some code works. Comments are ignored when running the program.

Dyon uses // for single-line and /* */ for multi-line comments.

/*

This text is inside a multi-line comment.
It is ignored when running the program.

*/

fn main() {
    // Can I ask you something?
    println("hello?")
}

A single-line comment ignores the rest of the line:

#![allow(unused)]
fn main() {
println("hello") // Prints `hello`.
}

A multi-line comment starts with /* and ends with */.

#![allow(unused)]
fn main() {
/* testing, testing! */
println("hello")
}

You can nest /* */:

#![allow(unused)]
fn main() {
/*
    /*
    A comment inside a comment!
    */
*/
}

Tips and tricks

It is more common to use // than /* */ for documenting the code.

End a comment with a dot to make it easier to see where the line is ending:

#![allow(unused)]
fn main() {
// Alice opened the door
// by pressing a button.
}

You can use /* */ to ignore some code without removing it:

/*
fn main() {
    println("one")
}
*/

fn main() {
    println("two")
}

One technique that helps making code more understandable: Organize the code in paragraphs, like in a book. Write a single-line comment for each paragraph. Separate paragraphs with an empty line.

fn main() {
    // Print the numbers from 1 to 10.
    list := sift i 10 { i + 1 }
    println(list)

    // Print the numbers from 11 to 20.
    list := sift i [10, 20) { i + 1 }
    println(list)
}