开发者

Do both alter and ref-set update the STM tree in Clojure?

I am using refs everywhere in my Clojure code and then I realised I was using ref-set everywhere. Does this destroy the history of changes in the STM? Or should I be using alter only and ref-set to intialise the ref?

I am not sure if the difference is merely syntactical and alter开发者_Go百科 ends up calling ref-set anyway. Can someone enlighten me?


(alter aref f arg1 ... argn)

is basically the same as

(ref-set aref (f @aref arg1 ... argn))

Similar for atoms with reset! and swap!.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜