We're updating the issue view to help you get more done. 

enhance pprint to print type for defrecord (as in pr)

Description

pprint currently doesn't print the names of defrecord types, instead printing just the underlying map. This is in contrast to pr-str/println. This ticket proposes that the behaviour of pprint is changed to match pr-str and println's.

More discussion at https://groups.google.com/forum/#!topic/clojure-dev/lRDG6a5eE-s

1 2 3 4 5 6 7 8 9 10 11 12 user=> (defrecord myrec [a b]) user.myrec user=> (->myrec 1 2) #user.myrec{:a 1, :b 2} user=> (pr-str (->myrec 1 2)) "#user.myrec{:a 1, :b 2}" user=> (println (->myrec 1 2)) #user.myrec{:a 1, :b 2} nil user=> (pprint (->myrec 1 2)) {:a 1, :b 2} nil

Approach: Add new IRecord case to pprint's simple-dispatch mode. Extract guts of pprint-map to pprint-map-kvs and call it from both existing pprint-map and new pprint-record. Set multimethod preference for IRecord version. Added test.

1 2 user=> (pprint (->myrec 1 2)) #user.myrec{:a 1, :b 2}

Patch: CLJ-1890-pprint-records-2.patch

Prescreened by: Alex Miller

Also see: CLJS-1753

Environment

None

Status

Assignee

Unassigned

Reporter

Daniel Compton

Labels

Approval

Triaged

Patch

Code and Test

Affects versions

Release 1.8

Priority

Minor