Isn't core.async contrary to Clojure principles?

后端 未结 6 2029
日久生厌
日久生厌 2021-02-01 13:45

I have seen many Clojure programmers enthusiastic about the new core.async library and, though it seems very interesting, I am having a hard time seeing how it conforms to Cloju

6条回答
  •  一向
    一向 (楼主)
    2021-02-01 13:59

    The first concern - yes the core operations are side effects. However channels don't have the problems normally associated with mutable references as they don't represent a "place" - channels are opaque, you cannot inspect them, in fact you can't even query whether a channel is closed or not beyond reading nil.

    The second concern - doing anything more than shallow yield would mean whole program transformation. This is a tradeoff and I think a reasonable one. The level of composition is channels not go blocks and they compose just fine.

    The final concern, you can easily do Rx style map/filter/reduce operations over channels and people have already done so.

提交回复
热议问题