Clojure

Print control for Java collection types

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Duplicate
  • Affects Version/s: None
  • Fix Version/s: Release 1.5
  • Component/s: None
  • Labels:
    None
  • Approval:
    Vetted

Activity

Hide
Alex Miller added a comment -

Ah, sweet - thanks Stu!

Show
Alex Miller added a comment - Ah, sweet - thanks Stu!
Hide
Stuart Halloway added a comment -

This work was done in commit 92b4fc76e59e68d3bdae4ebd5b8deec915cb7ab5

Show
Stuart Halloway added a comment - This work was done in commit 92b4fc76e59e68d3bdae4ebd5b8deec915cb7ab5
Hide
Stuart Halloway added a comment -

This was actually implemented in 1.5. Andy's suggestion about Queue (see patch and https://groups.google.com/forum/#!topic/clojure-dev/q7h4QJCHEvw) could be considered as a separate feature request.

Show
Stuart Halloway added a comment - This was actually implemented in 1.5. Andy's suggestion about Queue (see patch and https://groups.google.com/forum/#!topic/clojure-dev/q7h4QJCHEvw) could be considered as a separate feature request.
Hide
Alex Miller added a comment -

Rich and Stu said this should be in scope for 1.6. Rich said that Stu would likely do the work.

Show
Alex Miller added a comment - Rich and Stu said this should be in scope for 1.6. Rich said that Stu would likely do the work.
Hide
Andy Fingerhut added a comment -

Just a comment: Clojure 1.5.1's behavior regarding print-readably and Java collections does seem a bit odd, perhaps backwards:

user=> (import '[java.util HashSet])
java.util.HashSet
user=> (def x (HashSet. (range 10)))
#'user/x
user=> (binding [*print-readably* true] (pr-str x))
"#{0 1 2 3 4 5 6 7 8 9}"
user=> (binding [*print-readably* false] (pr-str x))
"#<HashSet [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>"
Show
Andy Fingerhut added a comment - Just a comment: Clojure 1.5.1's behavior regarding print-readably and Java collections does seem a bit odd, perhaps backwards:
user=> (import '[java.util HashSet])
java.util.HashSet
user=> (def x (HashSet. (range 10)))
#'user/x
user=> (binding [*print-readably* true] (pr-str x))
"#{0 1 2 3 4 5 6 7 8 9}"
user=> (binding [*print-readably* false] (pr-str x))
"#<HashSet [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>"
Hide
Andy Fingerhut added a comment -

clj-1270-1.txt is just a quick swipe at changing the printing behavior for Java objects with classes implementing the java.util.Queue interface, so pr/pr-str shows them similarly to how they show Clojure lists and seqs. java.util.Set and java.util.List already pr/pr-str similarly to Clojure lists, vectors, or sets.

No change is made in this patch to the behavior of print/print-str, or to how other objects are printed whose classes implement java.util.Collection, but not also one of java.util.Set, .List, or .Queue.

A few tests are added to verify the desired behavior when print-length is set to a value other than nil.

Show
Andy Fingerhut added a comment - clj-1270-1.txt is just a quick swipe at changing the printing behavior for Java objects with classes implementing the java.util.Queue interface, so pr/pr-str shows them similarly to how they show Clojure lists and seqs. java.util.Set and java.util.List already pr/pr-str similarly to Clojure lists, vectors, or sets. No change is made in this patch to the behavior of print/print-str, or to how other objects are printed whose classes implement java.util.Collection, but not also one of java.util.Set, .List, or .Queue. A few tests are added to verify the desired behavior when print-length is set to a value other than nil.

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: