I wonder from purely language-design point of view which "features" (semantically and syntactically) an "implementation" of SI units would require.
Which "functionality" is generally expected if someone claims that a language has great support for units of measurements?
F#'s advantage over a Java UOM library is simple - type safety. You will get compile-time errors if you attempt to add
4.<m / s>.
In F#, UOM are erased after the type-checking, because it is the only .NET language with such feature.
In reply to comment, here is a simple fraction type and its usage:
type Fraction<[<Measure>] 'a>(a : int, b : int) = member __.Divisor = a member __.Dividend = b member __.AsFloat = float a / float b static member (*) (a : Fraction<'a>, b : Fraction<'b>) : Fraction<'a * 'b> = Fraction(a.Divisor * b.Divisor, a.Dividend * b.Dividend) type [<Measure>] m type [<Measure>] kg type [<Measure>] s let a = Fraction<m / s>(4, 3) let b = Fraction<kg>(2, 5) let ``a times b`` = a * b
And the value returned is of type
Fraction<kg m/s> and its
AsFloat value is