【发布时间】:2016-09-19 20:14:20
【问题描述】:
使用来自 F# v4.0 的 Visual Studio 2015 Update 3 和 fsi.exe 我正在尝试运行此脚本:
//error.fsx
#if INTERACTIVE
let msg = "Interactive"
#else
let msg = "Not Interactive"
#endif
let add x y =
x + y
printfn "%d" (add 1 2)
输出: error.fsx(12,15): error FS0039: The value or constructor 'add' is not defined
如果我随后注释掉 #if-#else-#endif 块,它可以正常工作:
// fixed.fsx
//#if INTERACTIVE
// let msg = "Interactive"
//#else
// let msg = "Not Interactive"
//#endif
let add x y =
x + y
printfn "%d" (add 1 2)
输出: 3
我确定我做错了什么(而不是这是一个错误),但我一生都无法弄清楚如何使这项工作发挥作用。
想法?
【问题讨论】:
标签: f# f#-interactive f#-scripting f#-4.0