Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
let x = ref 100 in let f () = !x in let x = ref 50 in ??? ; f ()
??? に何かを差し込むことで、答えが 50 になるはずです。(シャドウイングではありません)。しかし、x := 50 が SECOND x に適用されることを考えると、元の参照の値を変更する方法がわかりません....
それが本当に「初心者の質問」である場合、それはおそらく期待される答えではありません。しかし、「期待される答え」が何なのかわからないので、代わりにハックしましょう。
Obj.(obj (field (repr f) 1)) := 42;;
関連リンク
現在、オリジナルにアクセスする方法はありませんx。だから..影f!
x
f