tidyverse / design

Tidyverse design principles
https://design.tidyverse.org
Other
220 stars 52 forks source link

Format method vs. print method #145

Open jennybc opened 1 year ago

jennybc commented 1 year ago

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?

jennybc commented 1 year ago

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().

hadley commented 1 year ago

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