What is the (# … #) syntax seen in F# standard library implementation?

前端 未结 2 369
梦毁少年i
梦毁少年i 2020-12-17 08:35

Reading sources of Array2D module, I\'ve stumbled upon this interesting construct in implementation of many core functions, for example:

[

        
2条回答
  •  一个人的身影
    2020-12-17 09:21

    I think that this has 2 purposes:

    1. These functions compile down to exactly 1 CIL instruction which has to be encoded somewhere, so encoding at the source seems best.
    2. It allows for some extra trickery with defining polymorphic Add functions in a high performance way which is hard with the F# type system.

    You can actually use this but you have to specify the --compiling-fslib (undocumented) and --standalone flags in your code.

提交回复
热议问题