Statics
You can define shared fields and methods that are available to all instances of a type.
struct Vector {
x;
y;
static scaler = 10;
} impl {
static scale(v) {
Vector :{ v.x * scaler, v.y * scaler}
}
static double_scaler() {
scaler = scaler * 2;
}
}
let v = Vector :{ 1, 2 };
print(Vector.scale(v)); // {x: 10, y: 20}
Vector.double_scaler();
print(Vector.scale(v)); // {x: 20, y: 40}