F# special quotes? (##)

后端 未结 3 1738
一向
一向 2021-01-02 01:02

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

(# \"sizeof !0\" type(\'T) : native         


        
相关标签:
3条回答
  • 2021-01-02 01:27

    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)))
    
    0 讨论(0)
  • 2021-01-02 01:34

    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.

    0 讨论(0)
  • 2021-01-02 01:42

    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.

    0 讨论(0)
提交回复
热议问题