async/map is supposed to close its output channel when one of the
channels in the collection signals that it is closed.
I had assumed that it would do the same when the collection is empty,
but it blocks (i witnessed that on clojurescript)
Now it's easy to work around that but not very nice to look at :
my nice function
(defn check-preds[router funcs]
(->> funcs
(map (partial check-pred router)) ; an array of chans
(a/map identity) ; a chan of maybe routers
(a/reduce >> (just router)))) ; a chan with a single maybe
router
now looks like this :
(defn check-preds [router funcs]
(if (seq funcs)
(->> funcs
(map (partial check-pred router))
(a/map identity)
(a/reduce >> (just router)))
(a/to-chan [(just router)])))
Which is way uglier !
I make the case to fix this.
The cost would be low : add a seq test inside async/map
The impact would be low : if anyone is risking to wait on an empty
channel collection, they would have the check demonstrated above, and
the change would not affect them. And I can't see why anyone would rely
on the current behavior.
The benefit : The library user's code looks nicer, and more
compositional, reducing the risks for errors and increasing readability.
I hope I haven't overlooked something obvious.
Sacha De Vos
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.