Modules and Code Organization

In this chapter, we'll explore organize your code with mana's module system.

Modules and Code Organization

As you write larger programs, organizing your code becomes increasingly important. Mana's module system helps you group related functionality, control visibility, and manage code across multiple files.

In this chapter, we'll cover:

The Module Declaration

Every Mana file begins with a module declaration:

module main
 
fn main() -> void {
    println("Hello, world!")
}

The module statement declares what module this file belongs to. This is required at the top of every .mana file.

Let's start with Module Declarations.