On Wednesday, December 21, 2016 at 7:24:17 AM UTC-6, Mike Rodriguez wrote:
>
>
> Also, since `reduce` doesn't work like I'd expect here, it makes me 
> question if I could rely on the fact that `sequence` and `eduction` do 
> happen to work out right now.
>

I think that's an artifact of the implementation and you should not rely on 
it.
 

> I bring this up here because it has snuck up on me a few times.  I haven't 
> found many java.util.Map impl's in the wild that cause this trouble beyond 
> java.util.IdentityHashMap.  However, it worries me that I need to check 
> each impl I may use if I'm going to trust anything that `reduce`s on it.  I 
> tend to just completely avoid it with Java iterop now due to not knowing 
> what Clojure's guarantees are.  So I just use an explicit `loop` + `recur` 
> that manually traverses the entry set via its iterator one at a time for 
> these sorts of maps.
>

That is a good approach.
 

> I'm curious to see others' thoughts on this issue.  One thought I had was 
> that `clojure.core.protocols/CollReduce` could provide an explicit 
> implementation of `coll-reduce` for java.util.Map that (recursively) called 
> `coll-reduce` on it's Iterable entry set.  This would avoid this particular 
> issue it looks like at least.
>

That sounds like a good idea to me. I think the major potential issue is 
that it creates ambiguity and non-deterministic dispatch for Clojure maps 
in CollReduce (as IPersistentMaps are both Iterable and Seqable). So that 
would need to be resolved.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to