F# 特殊引号? (##)

发布于 2024-11-04 22:52:56 字数 430 浏览 8 评论 0原文

我刚刚跑过 http://frankniemeyer.blogspot.com/2010/ 04/minimalistic-native-64-bit-array.html 其中包含一行

(# "sizeof !0" type('T) : nativeint #)

我相信技术短语是“到底是什么?”在我(大约 8 个月)的 F# 编程中,我从未遇到过类似的情况...

FSI 告诉我一些有关已弃用的构造的信息,仅用于 F# 库...

谷歌搜索 (# 呃...嗯,不多

这方面有什么方向吗?

I just ran across
http://frankniemeyer.blogspot.com/2010/04/minimalistic-native-64-bit-array.html
Which contains the line

(# "sizeof !0" type('T) : nativeint #)

I believe the technical phrase is "what the heck?" I have never in my (~8 months) of F# programming run across something even resembling that...

FSI tells me something about deprecated constructs, used only for F# libs...

And google with (# does uh...well, not much

Any direction in this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

娇纵 2024-11-11 22:52:56

这是内联 IL 发射的符号。它曾经是 F# 早期的一个更突出的功能,但已被弃用。 F# 团队中一位名叫 Brian 的先生表示,它目前主要用于引导 F# 编译器,并且该团队打算将此构造标记为错误,而不仅仅是警告。

请参阅此处了解完整故事。

This is the notation for inline IL emission. It used to be a more prominent feature during F#'s earlier years, but has been deprecated. A gentleman named Brian from the F# team has indicated that it is currently used mainly to bootstrap the F# compiler, and that the team had intended to mark this construct as an error, not merely a warning.

See his post here for the full story.

夏雨凉 2024-11-11 22:52:56

它是内联 IL(中间语言)代码。此构造由 F# 团队在内部使用,以实现您无法通过任何其他方式执行的 F# 核心库的某些部分。此代码将接受一个警告,表明它不应在 F# 核心库以外的任何地方使用,因此您可能不必太担心它,因为它永远不会出现在生产代码中。

It's inline IL (intermediate language) code. This construct is used internally by the F# team to implement bits of the F# core library you just can't do any other way. This code will admit a warning saying it shouldn't be used any where other than the F# core libraries, so you probably don't have to worry about it too much as it should never appear in production code.

吃素的狼 2024-11-11 22:52:56

迷人。但我认为 F# 已经为我们提供了所需的转换操作(对于此特定操作!),而无需诉诸 IL。

[<Unverifiable>]
let inline ArrayOffset (itemSize:int64) (length:int64) (start:int64) (idx:int64) = 
    if idx < 0L || idx >= length then raise(IndexOutOfRangeException())
    NativePtr.ofNativeInt(nativeint(start + (idx * itemSize)))

Fascinating. But I think F# already gives us the conversion operations (for this particular operation!) you need without resorting to IL.

[<Unverifiable>]
let inline ArrayOffset (itemSize:int64) (length:int64) (start:int64) (idx:int64) = 
    if idx < 0L || idx >= length then raise(IndexOutOfRangeException())
    NativePtr.ofNativeInt(nativeint(start + (idx * itemSize)))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文