Does F# provide you automatic parallelism?

2019-02-02 08:54发布

By this I meant: when you design your app side effects free, etc, will F# code be automatically distributed across all cores?

8条回答
Melony?
2楼-- · 2019-02-02 09:22

Well, you have your answer, but I just wanted to add that I think this is the most significant limitation of F# stemming from the fact that it is a hybrid imperative/functional language.

I would like to see some extension to F# that declares a function to be pure. That is, it has no side-effects that are not denoted by the function's type. The idea would be that a function is pure only if it references other "known-pure" functions. Of course, this would only be useful if it were then possible to require that a delegate passed as a function parameter references a pure function.

查看更多
We Are One
3楼-- · 2019-02-02 09:24

On purity annotations: Code Contracts have a Pure attribute. I remember hearing the some parts of the BCL already use this. Potentially, this attribute could be used by parallellization frameworks as well, but I'm not aware of such work at this point. Also, I' not even sure how well code contacts are usable from within F#, so a lot of unknowns here.

Still, it will be interesting to see how all this stuff comes together.

查看更多
登录 后发表回答