Isn't core.async contrary to Clojure principles? -


i have seen many clojure programmers enthusiastic new core.async library and, though seems interesting, having hard time seeing how conforms clojure principles, have these questions:

  1. it uses mutable state everywhere, function names suggest having exclamation mark, alt!, put!, >!, , others. if put or take value channel, channel modified inplace. isn't contrary clojure philosophy of preferring immutable data-structures, pure functions , on? or core.async made used mutable things not avoided @ all?
  2. since "go" macro (thus modifying code structure) , ensures "<!" used directly in go-block, not possible use "<!" inside function, this:

    (defn take-and-print [c]  (println (<! c)))  (def ch (chan 1)) (>!! ch 123)  (go (take-and-print ch))  assert failed: <! used not in (go ...) block 

    it seems me prevents simplicity , composability. why not problem?

  3. maybe consequence of previous 2 issues, lot of code core.async uses lower-level constructs such loop/recur instead of map/filter/reduce. isn't step backwards?

where missing point?

thanks in advance.

the first concern - yes core operations side effects. channels don't have problems associated mutable references don't represent "place" - channels opaque, cannot inspect them, in fact can't query whether channel closed or not beyond reading nil.

the second concern - doing more shallow yield mean whole program transformation. tradeoff , think reasonable one. level of composition channels not go blocks , compose fine.

the final concern, can rx style map/filter/reduce operations on channels , people have done so.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -