我想知道为什么在 OCaml 中,let ... and
没有与type ... and
.
以下是可以的,与以下内容t2
在同一范围内t1
:
# type t1 = t2
and t2 = int;;
以下是错误的,v2
不在范围内:
# let v1 = v2
and v2 = 3;;
Characters 9-11:
let v1 = v2
^^
Error: Unbound value v2
甚至let rec
不起作用:
# let rec v1 = v2
and v2 = 3;;
Characters 13-15:
let rec v1 = v2
^^
Error: This kind of expression is not allowed as right-hand side of `let rec'
type... and
为什么和之间的范围界定不一致 let...and
?