Modules
import std.mathimport std.str
println(math.abs(-5))println(str.to_upper("hi"))Selective and aliased imports
Section titled “Selective and aliased imports”import app.math(add as f) // bare fimport app.utils.helpers as himport shapes(Tokens) // bring a type into scopePackage imports
Section titled “Package imports”Inside a project (nearest zz.toml), the package name maps to src/ from any file:
import app.math // <root>/src/math.zz as math.*import app // <root>/src/main.zz as app.*Rules: std > package > registry dep > relative file.
- and _ spellings agree (my-app is my_app).
One file may live under several namespaces at once; the first binding wins as
canonical and aliases rewrite through it so types keep one identity.
Two different files under one namespace stay an error — alias one side.
Relative files
Section titled “Relative files”The CLI resolves imports relative to the importing file:
project/ main.zz utils/helper.zz // import utils.helper from main.zzCircular imports are rejected
Section titled “Circular imports are rejected”a.zz imports b.zz, which imports a.zz -> errorFix: extract shared types into c.zz; both a and b import c.
Cross-module types
Section titled “Cross-module types”struct Point { x: int, y: int }
// main.zzimport shapesp := shapes.Point{ x: 1, y: 2 }pub type / pub enum export aliases and enums. Dotted declarations
(func shapes.distance(...), struct shapes.Point) define into a namespace.
Next: Project layout, Packages.