PLDB
Languages Features Calendar CSV Lists Blog About Sponsor Add Language
GitHub icon

Units of Measure

Units of Measure

Units of Measure is a feature.

Some languages have builtin units of measurement.


Languages without Units of Measure include Python, C++, Elixir, Bash

Languages with Units of Measure include F#, Nemerle, Modelica, Frink, TI-89 series

Example from F#:
// 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 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 Modelica:
type SpecificHeatCapacity = Real ( final quantity="SpecificHeatCapacity", final unit="J/(kg.K)" );
Example from Frink:
10 feet 12 feet 8 feet -> gallons
Example from TI-89 series:
54_kg * (_c^2)
unary-operators-feature.html 路 units-of-measure-feature.html 路 virtual-functions-feature.html

View source

PLDB - Build the next great programming language 路 v2022 Day 33 Docs Build Acknowledgements Traffic Today Traffic Trends Mirrors GitHub feedback@pldb.com