ここでの副次的な質問として、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
この行動の不一致がある理由に関するガイドラインやその他のリソースはどこにありますか? それは特定のコンパイラ/言語に結び付けられていますか、それともすべての関数型言語に適用される理論がありますか?