Imports and Modules
Vexel programs can be split across multiple source files. The import statement brings the declarations from another file into the current scope.
Basic Import
Use import followed by a quoted file path (relative to the current file). All top-level declarations in the imported file become available.
# math.vx
fn square(n: int) -> int:
return n * n
fn cube(n: int) -> int:
return n * n * n # main.vx
import "math.vx"
fn main():
print(square(4)) # 16
print(cube(3)) # 27 Import with Alias
Use as to bind the imported module to a namespace alias. All declarations from the file are then accessed through that alias using dot notation.
import "math.vx" as math
fn main():
print(math.square(5)) # 25
print(math.cube(2)) # 8 Built-in Modules
Vexel provides built-in modules that are always available without a file path.