Guide
Units
Erased at compile time, with no runtime representation whatsoever.
A duration, a distance and an angle can be written with a unit, and the unit is gone by the time anything runs. Nothing of it survives into the output, so a value costs exactly what its number costs.
Erased, completely
30m generates the number 30. 250ms generates 0.25, because seconds are the base unit. 90deg generates radians at the literal. Nothing survives into the emitted code.
// Integers say what they do when a result does not fit. There is no undefined behaviour.
//
// A plain `+` fails rather than producing a value outside the type. `+%` wraps and `+|` saturates,
// and choosing is the point: a health bar saturates, a hash wraps, a count should fail.
fn health(current: u8, healed: u8) -> u8 {
return current +| healed
}
fn hashStep(accumulator: u32, value: u32) -> u32 {
return accumulator *% value
}
// Units are erased. `30m` is the number 30; `250ms` is 0.25, because seconds are the base unit.
fn reach() -> f32 {
return 30m
}
fn beat() -> f32 {
return 250ms
}
Why erasure rather than a type
A unit that survived into generated code would cost an object per value, and the hosts this language targets budget zero allocations in a per-frame path. A units system nobody can afford to use in the loop is a units system for the parts that did not need one.
What that costs
Since a unit is not a type, the compiler cannot stop you adding a duration to a distance. The conversion is checked; the dimension is not. That is the trade, and it is stated rather than discovered.