tidyverse/design

Format method vs. print method

Opened this issue · 2 comments

I think it would be good to write up what belongs in a format method vs. a print method. Mostly conveying that, when in doubt, put the smarts in the format method and do as little as possible in print.

Possible secondary question: should you implement a str() method? What's the difference between format/print and str?

A good (anti) example is how hard it is to capture the printed "look" of a data.frame. Basically you have to use capture.output().

If you do write a format method, should it return a single string, or a character vector with one element per line?