pqn*_*net 6 f# computation-expression
在任何控制流语句中使用af#计算表达式的自定义操作都无法进行类型检查
error FS3086: A custom operation may not be used in conjunction with 'use',
'try/with', 'try/finally', 'if/then/else' or 'match' operators within this
computation expression
Run Code Online (Sandbox Code Playgroud)
为什么不允许这样做?什么是自定义操作,不允许重写此:
expr {
if a then
custom (x)
else
return (y)
}
Run Code Online (Sandbox Code Playgroud)
这样的事情:
expr {
return!
if a then
expr { custom (x) }
else
expr { return (y) }
}
Run Code Online (Sandbox Code Playgroud)