Signature Files and Access Modifers in F#

风流意气都作罢 提交于 2019-12-04 03:26:38
Brian

They accomplish almost the same thing. (Note that you can use an .fsi file for types in namespaces too, was unsure what your comment about that meant.)

A signature file has a couple advantages:

  • You can make entities public for the duration of the file, but then private to the subsequent files of the project.
  • You can have just your short summary in the signature file, so the public interface is easy to read without having to scan tons of code.

The first bullet is not to be trifled with - within-assembly encapsulation like this is actually a pretty huge feature for very large projects. Being able to define a few types which are public to one another within File1.fs, but then only have a subset of those types/methods be public to the rest (File2.fs, File3.fs, etc.) is quite useful (a little bit like 'friend' in C++).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!