相关疑难解决方法(0)

对F#度量单位的反思

目前已在F#中添加了对反射的支持,但它不适用于度量类型.是否可以在F#中使用反射来测量类型?我读过这个.它是在2008年,但是如果你在ildasm中查看一些像bellow这样的代码你就看不出任何东西了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
Run Code Online (Sandbox Code Playgroud)

ildasm输出:

.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
Run Code Online (Sandbox Code Playgroud)

所以有些东西无法在F#中反映出来.这是真的吗?看到评论:CLR中的单位实际上根本没有被看到......在文章中.

c# reflection f#

8
推荐指数
1
解决办法
1313
查看次数

标签 统计

c# ×1

f# ×1

reflection ×1