3
作为一个侧面的问题在这里What's the easiest way to do something like delegate multicast in F#我认为用适当的标题提出一个完整的问题可能会更好。点自由函数不会导致递归,但正常的函数会在这里?
该版本不会造成递归:(这里notify
似乎不可改变的d
)
let mutable notify = fun x -> x
let wrap f i = f(i); i
let a x = printf "%A" x
let d = (notify >> (wrap a)) // point free
notify <- d
notify "ss"
这个版本会。 (这里notify
在d
似乎可变)
let mutable notify = fun x -> x
let wrap f i = f(i); i
let a x = printf "%A" x
let d x =
(notify >> (wrap a)) x // normal function
notify <- d
notify "ss" // endless loop
另一个失败的版本:
let mutable notify = fun x -> x
let wrap f i = f(i); i
let a x = printf "%A" x
let d =
fun x -> (notify >> (wrap a)) x // Here
notify <- d
notify "ss" // endless loop
我在哪里可以找到任何指导或更多资源到我们为什么有这样的行为差异。它是否与特定的编译器/语言绑定,或者是否存在适用于所有功能语言的理论?