Support for reflection has been currently added into F#, but it is not working for measure types. Is it possible to use reflection in F# for measure types?
I've read this. It was for 2008, but if you check some code like bellow in ildasm you cannot see anything about Units of Measure
.
// Learn more about F# at http://fsharp.net
[<Measure>] type m
[<Measure>] type cm
let CalculateVelocity(length:float<m> ,time:float<cm>) =
length / time
The ildasm output:
.method public static float64 CalculateVelocity(float64 length,
float64 time) cil managed
{
// Code size 5 (0x5)
.maxstack 4
IL_0000: nop
IL_0001: ldarg.0
IL_0002: ldarg.1
IL_0003: div
IL_0004: ret
} // end of method Program::CalculateVelocity
So there are somethings that cannot be reflected in F#. Is it true or not? see the comment : Units actually don't get seen at all by the CLR ... in the article.
See Question&Answers more detail:os