如何F#度量单位的工作? [英] How do F# units of measure work?

查看:134
本文介绍了如何F#度量单位的工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人有机会深入探讨如何<一个href="http://blogs.msdn.com/andrewkennedy/archive/2008/08/20/units-of-measure-in-f-part-one-introducing-units.aspx"相对=nofollow> F#测量单位工作?难道仅仅是基于类型的诈骗,还是有CLR类型躲在下面,可以(可能)从其他.NET语言中使用?它会为任何数值单位工作,或者是仅限于浮点值(这是所有的例子都使用了什么)?

Has anyone had a chance to dig into how F# Units of Measure work? Is it just type-based chicanery, or are there CLR types hiding underneath that could (potentially) be used from other .net languages? Will it work for any numerical unit, or is it limited to floating point values (which is what all the examples use)?

推荐答案

据<一href="http://blogs.msdn.com/andrewkennedy/archive/2008/08/22/units-of-measure-in-f-part-two-unit-conversions.aspx#8920660">response在下一个相关的博客文章,他们在F#编译器纯静态机制。因此,有单位的数据没有CLR重新presentation。

According to a response on the next related blog post, they are a purely static mechanism in the F# compiler. So there is no CLR representation of the units data.

它并不完全清楚其当前是否适用于非浮型,但是从类型系统的角度看,它在理论上是可能的。

Its not entirely clear whether it currently works with non-float types, but from the perspective of the type system it is theoretically possible.

这篇关于如何F#度量单位的工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆