arcadia-unity / Arcadia

Clojure in Unity
http://arcadia-unity.github.io/
Apache License 2.0
1.68k stars 108 forks source link

jagged printing in emacs #320

Open timsgardner opened 6 years ago

timsgardner commented 6 years ago

Functions that involve multiple calls to print, println, (.Write ^TextWriter w "bla"), etc – basically anything that writes to *out* in multiple steps – are prone to print to the emacs repl in a garbled form, with newlines inserted and removed seemingly at random. This makes data almost unreadable. For example, the following:

(pprint
  (let [f (fn f [i]
            (if (<= i 0)
              :leaf
              (vec
                (repeatedly 3
                  #(f (dec i))))))]
    (f 4)))

prints as:

[[
[[:leaf :leaf
 :leaf] [:leaf :leaf :leaf] [:leaf :leaf :leaf]]
  [[:leaf :leaf :leaf] [:leaf :leaf
 :leaf] [:leaf :leaf :leaf]]
  [[:leaf :leaf :leaf] [:leaf :leaf :leaf] [:leaf :leaf :leaf]]]
 [[[:leaf :leaf :leaf] [:leaf :leaf :leaf] [:leaf :leaf :leaf]]

[[:leaf :leaf :leaf] [:leaf :leaf :leaf] [:leaf :leaf :leaf]]
  [[:leaf :leaf :leaf] [:leaf :leaf :leaf] [:leaf :leaf :leaf]]]

[[[:leaf :leaf :leaf] [:leaf :leaf :leaf] [:leaf :leaf :leaf]
]
  [[:leaf :leaf
 :leaf] [:leaf :leaf :leaf] [:leaf :leaf :leaf]]

[[:leaf :leaf :leaf] [:leaf :leaf :leaf] [:leaf :leaf :leaf]]]]

In Nostrand it evidently prints as

[[[[:leaf :leaf :leaf] [:leaf :leaf :leaf] [:leaf :leaf :leaf]]
  [[:leaf :leaf :leaf] [:leaf :leaf :leaf] [:leaf :leaf :leaf]]
  [[:leaf :leaf :leaf] [:leaf :leaf :leaf] [:leaf :leaf :leaf]]]
 [[[:leaf :leaf :leaf] [:leaf :leaf :leaf] [:leaf :leaf :leaf]]
  [[:leaf :leaf :leaf] [:leaf :leaf :leaf] [:leaf :leaf :leaf]]
  [[:leaf :leaf :leaf] [:leaf :leaf :leaf] [:leaf :leaf :leaf]]]
 [[[:leaf :leaf :leaf] [:leaf :leaf :leaf] [:leaf :leaf :leaf]]
  [[:leaf :leaf :leaf] [:leaf :leaf :leaf] [:leaf :leaf :leaf]]
  [[:leaf :leaf :leaf] [:leaf :leaf :leaf] [:leaf :leaf :leaf]]]]

Among other things, this could be:

This is a fairly major issue because it makes complex data unreadable.

saikyun commented 5 years ago

Does the same thing happen if you use the standard read function? It seems similar to the issue where the repl gets stuck, which doesn't happen when you use the standard read function (as described in #292).