You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I made the mistake of using for instead of doseq for running side effects multiple times in a row, which (to the best of understanding) resulted in the side-effects not happening immediately, instead they only happen when evaluating the result.
The problem is that when evaluating it with Ctrl+Enter, the println output is shown as part of the string representation of the output, instead of how it's supposed to be:
(def inventory {:wood 2 :iron 2})
(defn show-item [type amount] (format "%s: %d" (name type) amount))
(defn simplified-draw-inventory
[separator inventory]
(for [[type amount] inventory]
(println separator
(show-item type amount))))
(comment
(def x (simplified-draw-inventory "\n--------\n" inventory))
x
x
(println "foo")
:rcf)
In each screen part, the first red square is the lazy-seq version, and the second is running println directly.
I can see the output terminal's behavior being something unavoidable as long as you want to show the string representation as it's being generated, but the inline output's behavior is weird to me - evaluating (println "foo") doesn't show foo at all, while if that happens as a side-effect of transforming the result into a string (such as with lazy-seq), it does appear there!
(It originally happened when calling simplified-draw-inventory directly, I bound it to x just for the example)
The text was updated successfully, but these errors were encountered:
There seems to be something up with the nrepl printer function nrepl.middleware.print/print which Calva uses by default. In theory you should be able to work around it by specifying the printFn of cider.nrepl.pprint/pr, and then you also need to use client side pretty printing (the calva print engine). Like so:
Calva v2.0.474 is out now, and the workaround config should work. Let's keep this issue open a while and see if we can get some clarity around the nrepl.middleware.print/print issue.
I made the mistake of using
for
instead ofdoseq
for running side effects multiple times in a row, which (to the best of understanding) resulted in the side-effects not happening immediately, instead they only happen when evaluating the result.The problem is that when evaluating it with Ctrl+Enter, the
println
output is shown as part of the string representation of the output, instead of how it's supposed to be:In each screen part, the first red square is the
lazy-seq
version, and the second is runningprintln
directly.I can see the output terminal's behavior being something unavoidable as long as you want to show the string representation as it's being generated, but the inline output's behavior is weird to me - evaluating
(println "foo")
doesn't showfoo
at all, while if that happens as a side-effect of transforming the result into a string (such as withlazy-seq
), it does appear there!(It originally happened when calling
simplified-draw-inventory
directly, I bound it tox
just for the example)The text was updated successfully, but these errors were encountered: