Units of Measure

Define and track units to reduce dimensional-analysis bugs.

Units of Measure

Units of measure remain an important part of the language model because they connect Sounio to scientific correctness, not just syntax aesthetics. The correct documentation stance today is that units exist in the language and checker design, but end-to-end enforcement still needs to be described conservatively.

Current contract

  • Unit and quantity syntax are part of the language story and of the active checker work.
  • The checked artifact advertises units of measure as a language feature.
  • Public docs should still present unit enforcement as partial unless a specific path has been verified in the current artifact or tests.

Model-level unit syntax

unit kg;
unit m;
unit s;

let speed: Quantity[f64, m/s] = 3.0@Quantity[f64, m/s]

Where to inspect implementation work

  • self-hosted/check/units.sio is the most direct place to inspect current self-hosted unit checking work.
  • docs/compiler/UNIT_RUNTIME_CHECKING.md and related compiler docs provide additional context for the intended enforcement model.
  • Scientific examples and tests are the right place to look for the safest current claims, especially where units interact with domain logic.

Documentation guidance

  • Teach units as part of the language design and current checker effort.
  • Avoid promising complete dimension-mismatch enforcement in every backend path unless you have verified it directly.
  • When units matter for safety or science claims, tie the docs back to a real fixture, benchmark, or gate artifact.