我有以下代码Test.fs
file:
namespace Testing
module test1 =
let Run =
printfn "Test1"
module test2 =
let Run =
printfn "Test2"
In my Program.fs
我正在打电话:
[<EntryPoint>]
let main argv =
let sw = Stopwatch.StartNew()
printfn "%A" Testing.test1.Run
sw.Stop()
printfn "Problem took %d minutes, %d seconds, and %d milliseconds" sw.Elapsed.Minutes sw.Elapsed.Seconds sw.Elapsed.Milliseconds
let s = Console.ReadLine()
0 // return an integer exit code
这输出
Test1
Test2
Why is Test2
即使我只是打电话,也正在输出Test1.Run
?
test1.Run
不是一个函数,它是一个值。当您打开一个模块时,您会执行该模块中的所有顶级代码。在这种情况下,您定义test1.Run
and test2.Run
它们都是绑定而不是函数。
我无法从您发布的内容中准确判断发生了什么,但很明显您的 main 函数没有被调用,否则printfn "%A" Testing.test1.Run
会打印<null>
and printfn "Problem took %d minutes, %d seconds, and %d milliseconds" sw.Elapsed.Minutes sw.Elapsed.Seconds sw.Elapsed.Milliseconds
也会打印一些东西。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)