brandonbloom / fipp

Fast Idiomatic Pretty Printer for Clojure
525 stars 44 forks source link

Implement print controls for limiting output size #10

Closed brandonbloom closed 8 years ago

brandonbloom commented 11 years ago
brandonbloom commented 9 years ago

wip: https://github.com/brandonbloom/fipp/tree/control

cichli commented 8 years ago

I think being able to limit the number of lines would still be useful - there does exist clojure.pprint/*print-lines* but it remains private and unused.

From a cursory glance at engine.cljc (I haven't read the code too deeply, or the paper yet), it seems that in the step fn of format-nodes we could keep track of the number of lines so far, and use reduced if the count exceeds the limit?

(happy to provide a PR to implement that, if you'd be interested!)

brandonbloom commented 8 years ago

If it's not implemented in Clojure, nobody is expecting it. So unless there's a compelling use case for it, I don't really think we need to bother implementing it. Further, I think this one is easy to implement on your own as a post-processing step. No changes are needed to the edn printer or the engine to implement it, you can just scan the output stream for newline characters.

brandonbloom commented 8 years ago

The other control parameters mentioned there are for circular structures and for shared structures. Similar feedback of YAGNI applies, but....

Circular structures can be implemented at the edn-printer level, tracking that here: https://github.com/brandonbloom/fipp/issues/11 Will add an extra note on it too.

print-shared can't reasonably be done without non-trivial space and I just don't think it's that useful in a generic way. You don't want to overdue sharing information for keywords or symbols, and then there's laziness to worry about and a bunch of other odd things. I'm just not worried about this.