// File: math/vector.cesiumnamespace math.vector;// Public interfacestruct Vector3 { f64 x, y, z; Vector3 = operator +(Vector3 other) { return Vector3 { x + other.x, y + other.y, z + other.z }; }}f64 = magnitude(Vector3 v) { return ::(v.x^2 + v.y^2 + v.z^2);}// Private helper functionprivate f64 = square(f64 x) { return x * x;}
Import Syntax
Basic Imports
// Import entire modulesimport(math.vector);import(std.io) as io;
Selective Imports
// Selective importsimport(math.matrix) { Matrix; multiply as mat_mult; invert };import(graphics.primitives) { Circle; Rectangle as Rect; export Triangle; // import as global name}
Using Imported Functions
// Using imported functionsVector3 v1, v2;Vector3 sum = math.vector.add(v1, v2);Matrix m = mat_mult(matrix1, matrix2);Triangle tri; // globally available due to 'export'
External Library Integration
C Library Imports
// Import C librariesextern libc = import('c') { i32 = printf(str fmt, ...); #void = malloc(uword size) as malloc; // global alias export void = free(#void ptr); // import as global}extern math_lib = import('m') { f64 = sin(f64 x); f64 = cos(f64 x); f64 = sqrt(f64 x) as sqrt;}