pp icon indicating copy to clipboard operation
pp copied to clipboard

Java array formatting

Open paintparty opened this issue 2 years ago • 6 comments

Found an edge case hiding in a corner ...

(clojure.pprint/pprint (into-array '(1 2 3)))
;; Prints:
;; [1, 2, 3]


(me.flowthing.pp/pprint (into-array '(1 2 3)))
;; Prints:
;; #object["[Ljava.lang.Long;" 0x346690d6 "[Ljava.lang.Long;@346690d6"]

paintparty avatar Nov 12 '24 20:11 paintparty

Thanks for reporting. I'll fix that.

eerohele avatar Nov 12 '24 20:11 eerohele

:pray:

paintparty avatar Nov 12 '24 20:11 paintparty

Interesting that clojure.pprint/pprint prints Java arrays differently from prn:

user=> (prn (byte-array [(int \a) (int \b) (int \c)]))
#object["[B" 0x77380939 "[B@77380939"]
nil
user=> (prn (into-array [1 2 3]))
#object["[Ljava.lang.Long;" 0x46ceabe5 "[Ljava.lang.Long;@46ceabe5"]
nil

eerohele avatar Nov 13 '24 06:11 eerohele

It is also interesting that clojure.pprint/pprint prints commas in arrays, but not in Clojure colls:

user=> (clojure.pprint/pprint (into-array [1 2 3]))
[1, 2, 3]
user=> (clojure.pprint/pprint [1 2 3])
[1 2 3]

I don't know that I want to pp to have that inconsistency.

eerohele avatar Nov 13 '24 07:11 eerohele

This should be fixed in 2024-11-13.77. Can you give it a try and let me know whether it's fixed for you?

eerohele avatar Nov 13 '24 08:11 eerohele

Works great on my side. Thanks for the quick fix!

paintparty avatar Nov 13 '24 19:11 paintparty