Closed cichli closed 8 years ago
Hi Michael,
It's very exciting to hear that Fipp is now the default in Cider! Thanks for taking on this work.
I might not have a chance for a few days to pull down the code and play with it. I'll take a super quick look at the code now and make some comments. While it's OK by me if the engine code gets a little hairy, I'd like to do my best to keep the pretty-document printer code as clean as possible, as it's a good reference for people writing printers for non-edn.
Cheers, Brandon
Looking at this code more carefully now... additional comments follow.
Removed the benchmarking commit, squashed the remaining commits, cleaned up the code a bit, fixed some edge cases, updated the docs.
@cichli Please try the master branch and make sure it still works as you'd expect. If it does, I'll cut a release.
Hi Brandon,
Thanks a lot for taking the time to look at the PR - and then to subsequently clean it up and merge it! pretty-coll
is indeed a much cleaner impl. I've checked out the changes locally and they work exactly as I'd expect. Looking forward to the release!
I'll add my part to the benchmarking discussion on the other PR.
Thanks,
Michael
OK released version 0.6.3 - Thanks again!
Hi, first of all, thanks for the great (and fast!) library :-).
Both options are analogous to (and default to)
*print-length*
and*print-level*
respectively.I also took a stab at improving the benchmark, using
test.check
to generate sample data usingany-printable
. Additionally, I've switched to using a stubbedWriter
implementation instead ofwith-out-str
to try and minimise any overhead.Here are results for the new benchmark, both before and after this change is applied - the impact is reasonably negligible for normal usage (i.e. when
:print-length
/:print-level
are not set). Please do try and verify these results locally!Notes on the implementation:
:print-length
is implemented by using atake
transducer to limit the number of lines returned by the relevantvisit-*
methods, iff:print-length
is set....
is appended to the collection being printed if its length exceeds:print-length
.:print-level
is implemented similarly to in Clojure itself - each time we call one of the relevantvisit-*
methods, we decrement its value, iff:print-level
is set. This is done by using a new instance ofEdnPrinter
rather than the dynamic binding approach used in Clojure.#
is printed instead of the contents of the collection if the current:print-level
is negative.Motivation for this change: we now use
fipp
as the default pretty-printer in CIDER, but would like a way to prevent accidental printing of infinitely long or recursive structures :-). Let me know if there's anything I've missed or you think I should change.