Modules
You can use export and import to create modules in your project. This is a functions-only feature.
export fn add(a, b) a + b
export fn subtract(a, b) a - bHere, we look for an add function from a math.ngn file within the same directory that your main.ngn file is in.
import { add } from "math.ngn"
fn main() { print(add(21, 3)) // 24}Relative path imports
Section titled “Relative path imports”import { add } from "./lib/math.ngn"Aliased imports
Section titled “Aliased imports”import { add as adder } from "math.ngn"Module imports
Section titled “Module imports”import * as Math from "math.ngn"
print(Math.subtract(10, 2)) // 5Default export
Section titled “Default export”fn add(a, b) a + b
export default addimport add from "math.ngn"