Skip to content

Imports

import "geometry";
fun main() Int {
var point = geometry.Point { x: 3, y: 4 };
return geometry.distanceSquared(point);
}

The .zp extension may be omitted.

Use braces to bring specific exports into the current scope:

import "geometry" { Point, distanceSquared };
fun main() Int {
return distanceSquared(Point { x: 3, y: 4 });
}
import "geometry" { distanceSquared as norm2 };

The alias only changes the local name.

import "std/convert" as conv;
fun main() Int {
println(conv.toString(42));
return 0;
}

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.