Skip to content

Modules

Code is organized logically into modules. A module may contain one or more other module(s), struct(s), function(s), or top level constant(s).

eisen
mod math {
    let PI = 3.1415
    struct Point {
        x: int
        y: int

        create(x: int, y: int) -> new self: Point {
            self.x = x
            self.y = y
        }
    }

    fn sqrt(x: flt) -> root: flt { ... }

    mod Trig {
        // associated code
    }
}

Entities within modules can be reference with the scope resolution operator.

eisen
let p = math::Point(10, 2)
math::sqrt(9)

Or, scope can be implicity determined if the using declaration is provided, which is limited to a specific scope

eisen
{
    // inside this block, we no longer need the 'math::' prefix
    using math
    sqrt(16)
}