<< Back to previous view

[CLJ-1270] Print control for Java collection types Created: 30/Sep/13  Updated: 18/Oct/13  Resolved: 18/Oct/13

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Release 1.5

Type: Enhancement Priority: Critical
Reporter: Alex Miller Assignee: Stuart Halloway
Resolution: Duplicate Votes: 0
Labels: None

Attachments: Text File clj-1270-1.txt    
Approval: Vetted


This feature is described at:

Comment by Andy Fingerhut [ 14/Oct/13 2:08 AM ]

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.

Comment by Andy Fingerhut [ 14/Oct/13 11:24 AM ]

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])
user=> (def x (HashSet. (range 10)))
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]>"
Comment by Alex Miller [ 18/Oct/13 7:59 AM ]

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

Comment by Stuart Halloway [ 18/Oct/13 8:41 AM ]

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.

Comment by Stuart Halloway [ 18/Oct/13 8:42 AM ]

This work was done in commit 92b4fc76e59e68d3bdae4ebd5b8deec915cb7ab5

Comment by Alex Miller [ 18/Oct/13 9:21 AM ]

Ah, sweet - thanks Stu!

Generated at Thu Jan 18 21:53:24 CST 2018 using JIRA 4.4#649-r158309.