繁体   English   中英

Visual Studio 2017问题与F#中的名称空间

[英]Visual studio 2017 problem with namespaces in F#

我在HelperFunctions.fs中编写了此代码:

namespace Tutorial1.HelperFunctions

module Factorials = 

    let rec fact n = 
        match n with
            | 0 -> 1
            | 1 -> 1
            | _ -> n * fact (n - 1)

然后在Tutorial.fsx中:

#load "HelperFunctions.fs"
open Tutorial1.HelperFunctions

module start = 
    let x = Factorials.fact 5
    printfn "%d" x

代码将按预期方式编译并返回120,但是:VS抛出FS0039错误:因子和Tutorial1命名空间,类型或模块未定义...尝试了open,module等的许多其他组合,但代码甚至没有编译。 我在这里没看到什么问题?

好吧,即使您在文件中包含#load,显然vstudio中文件的顺序也很重要。 我不得不将文件向上移动,但它确实有效

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM