[racket] Numbers with dimensions

From: Konrad Hinsen (konrad.hinsen at fastmail.net)
Date: Fri Oct 25 08:29:48 EDT 2013

Thomas Chust writes:

 > in that respect, the type system of F# may be noteworthy, too. The
 > support for dimensions is built into the language in that case.

Interesting. A quick Google search led me to 

  http://en.wikibooks.org/wiki/F_Sharp_Programming/Units_of_Measure

which says

   "Important: Units of measure look like a data type, but they
    aren't. .NET's type system does not support the behaviors that
    units of measure have, such as being able to square, divide, or
    raise datatypes to powers. This functionality is provided by the F#
    static type checker at compile time, but units are erased from
    compiled code. Consequently, it is not possible to determine
    value's unit at runtime."

So units were added as a special case to the type checker, rather than
implemented in terms of a generic type system. That approach should be
adaptable to any language that has some type checker to start with.

It's good to see unit checking in a near-mainstream language. I hope
others will follow.

Konrad.

Posted on the users mailing list.