Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Andrew Kennedy: F# Units of Measure

Download

Right click “Save as…”

Embed code for this video

Copy the code above to embed our video on your website/blog.

Close

Video format

Note: These selections will fall back to the next best format depending upon browser capability.

Close
Floating point values in F# can have associated units of measure, which are typically used to indicate length, volume, mass, and so on. The built-in type float takes an optional unit-of-measure parameter, written in angle brackets, in a similar way that types such as IEnumerable take a type parameter, as in IEnumerable<int>.

By using quantities with units, you enable the compiler to verify that arithmetic relationships have the correct units, which helps prevent programming errors like the one that led to NASA's Mars Climate Orbiter being lost in September 1999. This was due to confusion between metric and so-called "English" units of measurement.  The accident could have been prevented if the NASA engineers had been able to annotate their program code with units, and then employed static analysis tools or language-level type-checking to detect and fix any unit errors.

Andrew Kennedy is an MSR research scientist who implemented units of measure for F#. What did this involve? How does it work, exactly? What's next? Meet Andrew and learn all about F#'s latest language feature, units of measure.

Enjoy.

Information sources: http://msdn.com and http://blogs.msdn.com/andrewkennedy/

Tags:

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.