philoskim / debux

A trace-based debugging library for Clojure and ClojureScript.
468 stars 19 forks source link

Request to make output lines in REPL more concise with fewer lines #18

Closed Futurile closed 4 years ago

Futurile commented 4 years ago

This is a very trivial request because it's solely about how the debug output looks. It may be solely a question of personal preference.

I have been trying out a few debugging tools like Hashp, Spyscope and Tupelo

What I notice with the output of debux, is that it's taking a lot more lines in the REPL.

  1. Add output of the expression into the expression line Debux separates out the form and the output. In Spyscope you would do this:

    user=> (take 20 (repeat (spyx :dbug (+ 1 2 3))))
    :dbg (+ 1 2 3) => 6
    (6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6)

    In Debux:

    user=> (take 20 (repeat (dbg (+ 1 2 3))))
    
    {:ns user, :line 1}
    dbg: (+ 1 2 3) =>
    |   6
    (6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6)

    The value of the form (+ 1 2 3) is put on a new line and a | put ahead of it. I find this visually a bit confusing, I expect the output to be after the =>.

When you do it with debugn on something longer it becomes very spread out. This time using hashp (I had problems with Spyscope):

    user=> (inc #p (* 2 #p (+ 3 #p (* 4 5))))
    #p[user/eval9305:1] (* 4 5) => 20
    #p[user/eval9305:1] (+ 3 (* 4 5)) => 23
    #p[user/eval9305:1] (* 2 (+ 3 (* 4 5))) => 46
    47

Then with debux:

    ;; Example 2: we want the value of each step
    (dbgn (inc (* 2 (+ 3 (* 4 5)))))

    {:ns user, :line 1}
    dbgn: (inc (* 2 (+ 3 (* 4 5)))) =>
    | (* 4 5) =>
    |   20
    | (+ 3 (* 4 5)) =>
    |   23
    | (* 2 (+ 3 (* 4 5))) =>
    |   46
    | (inc (* 2 (+ 3 (* 4 5)))) =>
    |   47
    47

I would like dbg and dbgn to put the value of the form after the arrow (=>) on the same line. So this would become:

(dbgn (inc (* 2 (+ 3 (* 4 5)))))

    {:ns user, :line 1}
    dbgn: (inc (* 2 (+ 3 (* 4 5)))) =>
    | (* 4 5) => 20
    | (+ 3 (* 4 5)) => 23
    | (* 2 (+ 3 (* 4 5))) => 46
    | (inc (* 2 (+ 3 (* 4 5)))) => 47
    47

I find this view easier to understand the steps and see the output clearly.

philoskim commented 4 years ago

First of all, thanks for your suggestion and sorry for the late reply. I have been so busy with my new project these days.

I considered your suggestion seriously, but my conclusion is that consistency is more important than conciseness.

Of course, some short result can be shown in one line as you suggest. However, when the evaluated results are so long and massive, the results has to be split across the several lines.

If the evaluated result can be seen in the end of the same line in some case and can be seen in the start of the next line in another case, I think that it's not consistent. What I want is to see the evaluated results in the fixed position in a consistent way.

I am very sorry to say that your suggestion is not accepted.

Futurile commented 4 years ago

Hi Philos - understand, I appreciate the point and thank-you for considering it.