AutoOpen外部定义的模块

时间:2011-06-07 15:55:42

标签: f# module

有没有办法自动打开外部定义的模块?我希望它可以在整个项目中使用而无需在每个文件中打开它。这样的事情是理想的:

[<AutoOpen>]
module MyModule = YourNamespace.YourModule //ERROR: Ignoring attributes on module abbreviation

我也尝试了这个,它(假设)将外部定义的模块作为新模块的公共接口的一部分。

module MyModule = 
  module public YourModule = YourNamespace.YourModule //ERROR: Ignoring accessibility attribute on module abbreviation. Module abbreviations are always private.

1 个答案:

答案 0 :(得分:1)

这是一个很好的问题 - 允许这样做是有意义的。另一种方法是使用一些编译器参数来自动打开命名空间/模块,但我认为目前没有。

(似乎没有比我在评论中写的更好的答案,所以我将其复制为答案)