Clojure

clojure/set fns don't work with mutable sets

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: Release 1.3
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test
  • Approval:
    Ok

Description

You can't call union, intersection, difference, et al on a mix of Clojure sets and Java sets, because internally the fns assume that sets are clojure values that you can call conj, disj, etc. on.

This percolates up and causes problems for clojure.data/diff as well, since diff aspires to work for any collection, but uses clojure.set to deal with sets.

Possible solutions:

  1. clojure.set fns detect mutable sets and convert to values at the outset
  2. clojure.set doesn't do magic conversions for you. But diff, which is less perf-sensitive, can do so. diff makes immutable values out of mutable sets before handing off to clojure.set
  3. Let the caller beware: docstring in clojure.set tells you to use immutable sets.

Activity

Hide
Stuart Halloway added a comment -

Rich, do you like option #1 in the description, or option #2 + #3, or none of the above?

Show
Stuart Halloway added a comment - Rich, do you like option #1 in the description, or option #2 + #3, or none of the above?

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: