CLJ-1270 and the corresponding design page [1] describe this desired enhancement. The Release.Next planning page [2] says it is in limbo (desired but not done).
I was looking into implementing this enhancement, and had some questions about what changes are desired, exactly.
Is it desired that _every_ object with a class that implements interface java.util.Collection should use print-sequential?
A lot of them already do in Clojure 1.5.1, e.g. those that also implement interface java.util.Set or java.util.List (see below).
However, those with classes implementing interface java.util.Queue or java.beans.beancontext.BeanContext are not printed with print-sequential. It seems desirable to change java.util.Queue to do so, but I am not so sure about java.beans.beancontext.BeanContext or java.util.Collection in general.
Thanks,
Andy
Some details on java.util.Set and java.util.List:
All objects whose classes implement the java.util.Set interface, such as objects with class java.util.HashSet, already have a printed representation that looks just like Clojure persistent sets, as long as *print-dup* is false (the default). The method in core_print.clj specialized on interface java.util.Set calls print-sequential, which obeys *print-level* and *print-length* restrictions. For example:
Clojure 1.5.1
user=> (import '[java.util HashSet])
java.util.HashSet
user=> (def s (HashSet. (range 100)))
#'user/s
user=> (binding [*print-length* 15] (pr-str s))
"#{0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ...}"
Similarly, all objects with classes implementing interface java.util.List also have their contents printed using print-sequential, and either parentheses or square brackets around the elements, depending on whether the collection implements interface java.util.RandomAccess or not.