Use aprint when displaying value


Problem: when trace-ns is used, very long displays in the output stream is very hard to read when the fn calls are important and with voluminous data structure
Solution: Use Aprint library when printing value in the output string, now get syntax hightlighting and better layout of data structure
Tradeoffs: add a new dependency to tools.trace
Tests: yes, modify the cleanup fn to also clean the color information added by aprint, so 100% tests passed




Luc Préfontaine
October 30, 2014, 4:59 PM

I've looked into this. 'Inlining aprint' in tools.trace would be my first choice.
However we need to get Vlad Bokov to fill a CA (I do not see him in the list of contributors)
and to grant us the rights to include part of is source code in tools.trace.

Being a regular user of this tool, I find the arity avenue painful. It happens that we use this in
integrated test mode to nail issues. Then the output goes to a file were tty ansi commands
are not welcomed.

I think we need a mode state to enable/disable this feature. In the repl you would need a single
statement to get the colored output whatever trace fns you are calling. That can be part of your
user profile.

Eventually this could migrate to core.pprint but that will require some time before it ends up in a clojure release.

Meanwhile we can keep this isolated in tools.trace so it can be moved later elsewhere.

Comments ?

Luc Préfontaine
October 30, 2014, 6:50 PM

I sent an email to Vlad and the url to this ticket.
Will have a discussion off line first and then move along with the plan if we can.

October 31, 2014, 6:27 AM

Comment made by: razum2um

Hi Jérémie, Alex and Luc,

I'm the author of aprint and really happy about you like my lib
Here are my thoughts about it:

1) I really like the idea to push it into tools.trace
2) Currently all the clojure contrib-libs have same patch acceptance policy as the lang, which I already wondered about Try to understand, if a lib depends on another, the last one must share the same policy as the original, which is not the case, as I hardly stop accepting pull requests.
3) If you couldn't change this policy, I see "inlining" as best choice.

Now some points about the question "what will get inlined?"

4) I'm a bit surprised, that people don't share my intent to integrate it with repl like this, don't like colors, they simply like the layout. So coloring could be thrown away and we eliminate dependance on clansi. Or I could inline clansi (has MIT license), document a :^dynamic to turn on colors (which will get off by default)
5) Code for compact layout depends on jline and it's definitely won't get inside As such this will remain pprint/print-right-margin default value, which is 72 by default and isn't best choice in my opinion, but let it be. (or do you still run clojure on very old terminals?)
6) I don't see sense in introducing a new one :^dynamic for it, I suggest to rely on pprint/print-pretty and if it's true - use compact layout instead of pprint's default one

As such:

  • i could fill and sign a CA

  • prepare a dependent free patch for you, which includes only compact layout (and colors if you like) controlled by pprint/print-pretty and pprint/print-right-margin

Luc Préfontaine
February 18, 2015, 3:03 AM

Hi Vlad,

any change on this one ?

I am about to issue 0.7.9. Dunno if you had some time to do the above steps.

Luc P.

Luc Préfontaine
February 18, 2015, 3:05 AM


I still punch Clojure code on Hollerith cards so I am in unfamiliar territory when a line
exceeds 80 characters and the last 8 columns are not usable anyway


Luc Préfontaine







Code and Test