Share your thoughts in the 2024 State of Clojure Survey!

Welcome! Please see the About page for a little more info on how this works.

+1 vote
in ClojureScript by

Repro:

λ clj -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.11.54"}}}}' -M -m cljs.main --repl-env node
ClojureScript 1.11.54
cljs.user=> (require '[clojure.pprint :refer [pprint *print-right-margin*]])
nil
cljs.user=> (prn (with-out-str (binding [*print-right-margin* 20] (pprint {:a 1 :b 2 :c 3 :d 4}))))
"{:a 1,\n :b 2, \n :c 3, \n :d 4}\n"
nil

Note the spaces before the newlines after :b 2 and :c 3.

by
oops - I misread. Totally agree.

1 Answer

0 votes
by

I don't think so. Notice that pprint should print to stdout, and the extra spaces that you're seeing is actually the indentation which makes the print, well, pretty.

by
The spaces *after* the newlines (i.e. the indentation) put the pretty in the printing. The spaces between the comma and the newline are superfluous.

Compare with Clojure:

    λ clj -M -r
    Clojure 1.11.1
    user=> (require '[clojure.pprint :refer [pprint *print-right-margin*]])
    nil
    user=> (prn (with-out-str (binding [*print-right-margin* 20] (pprint {:a 1 :b 2 :c 3 :d 4}))))
    "{:a 1,\n :b 2,\n :c 3,\n :d 4}\n"
    nil
by
I stand corrected :)
...