任何人都可以解释为什么下面的第二个例子不会编译?
'测试2'给出了"错误FS0670:这个代码不够通用.类型变量^ a不能一概而论,因为它会逃避它的范围." 我无法理解此错误消息.
// Test 1
type test1<'a> = | A of 'a
with
override t.ToString() =
match t with
| A a -> a.ToString()
// Test 2
type test2<'a> = | A of 'a
with
override t.ToString() =
match t with
| A a -> string a
// Test 3
type test3<'a> = | A of 'a
with
override t.ToString() =
match t with
| A a -> string (a :> obj)
Run Code Online (Sandbox Code Playgroud) F#Interactive(fsi.exe)有一个引用给定程序集的指令:
>#help;;
[...]
#r "file.dll";; Reference (dynamically load) the given DLL
[...]
Run Code Online (Sandbox Code Playgroud)
我经常喜欢卸载/取消引用先前引用的程序集以重新编译它们.那可能吗?
编辑:我在MacOSX和Mono下运行fsi - 应该与windows下的命令行相同.