How to load external F# script file and use it in F# interactive?

后端 未结 3 854
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-16 12:11

I would like to load one or more .fsx files into the F# interactive and have all the functions defined in the .fsx files in scope so that I can dir

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-16 13:09

    If you don't declare a module in fsx file, it implicitly creates a module the same name as file name.

    Therefore, you can always refer to another fsx file using fully qualified names or opening respective modules before use. For example, in Script2.fsx you can do:

    #load "Script1.fsx"
    
    open Script1
    
    // Use functions in Script1.fsx
    // ...
    

提交回复
热议问题