跨多个文件拆分 F# 模块 [英] Split F# modules across multiple files
本文介绍了跨多个文件拆分 F# 模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以跨文件拆分 F# 模块?
Is it possible to split an F# module across files?
根据我手上的那本书,这本书可能已经过时了(F# 的基础)
According to the book I have it is, but the book is probably outdated (Foundations of F#)
推荐答案
显然不是:
C: empTim>type 1.fs 2.fs
1.fs
#light
module Module
let sayHello1 = printfn "Hello, "
2.fs
#light
module Module
let sayHello2 = printfn "world!"
C: empTim>fsc 1.fs 2.fs
Microsoft F# Compiler, (c) Microsoft Corporation, All Rights Reserved
F# Version 1.9.6.2, compiling for .NET Framework Version v2.0.50727
2.fs(2,1): error FS0191: An implementation of the file or module Module has already been given.
更新:F# 4.0 中的错误已更改,现在是:
Update: the error has changed in F# 4.0, it is now:
错误 FS0248:此程序集的两个部分中出现两个名为Module"的模块
error FS0248: Two modules named 'Module' occur in two parts of this assembly
其中 Module
是程序集的完全限定名称,包括命名空间部分.
where Module
is the fully qualified name of your assembly, including the namespace part.
这篇关于跨多个文件拆分 F# 模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文