Units of Measure is an actively used design pattern. Some languages have builtin units of measurement.

?Years Old

Languages with Units of Measure include f-sharp, frink, modelica, nemerle, ti-89-basic

Example from f-sharp:

// https://fsharpforfunandprofit.com/posts/units-of-measure/
[<Measure>] type N = kg m/sec^2

let force1 = 5.0<kg m/sec^2>    
let force2 = 5.0<N>

force1 = force2 // true

Example from frink:

10 feet 12 feet 8 feet -> gallons

Example from modelica:

type SpecificHeatCapacity = Real (
  final quantity="SpecificHeatCapacity",
  final unit="J/(kg.K)"

Example from nemerle:

def m3 = 1 g;
def m4 = Si.Mass(m1);

WriteLine($"Mass in SI: $m4, in CGS: $m3");

def x1 = Si.Area(1 cm * 10 m);

WriteLine($"Area of 1 cm * 10 m = $x1 m");

Example from ti-89-basic:

54_kg * (_c^2)

Last updated August 9th, 2020

Edit Units of Measure on GitHub