Imports
Import a module namespace
Section titled “Import a module namespace”import "geometry";
fun main() Int { var point = geometry.Point { x: 3, y: 4 }; return geometry.distanceSquared(point);}The .zp extension may be omitted.
Import selected names
Section titled “Import selected names”Use braces to bring specific exports into the current scope:
import "geometry" { Point, distanceSquared };
fun main() Int { return distanceSquared(Point { x: 3, y: 4 });}Rename an imported symbol
Section titled “Rename an imported symbol”import "geometry" { distanceSquared as norm2 };The alias only changes the local name.
Alias a module
Section titled “Alias a module”import "std/convert" as conv;
fun main() Int { println(conv.toString(42)); return 0;}Path resolution
Section titled “Path resolution”The compiler resolves imports relative to the importing file, from configured import mappings, and from the standard library.
Add a mapping in thor.toml:
[imports]"vendor" = "third_party/vendor"Thor passes every [imports] entry to the compiler. See Thor build
tool for project configuration, or the compiler
reference for low-level options.