Improving doc for display/print/show/repr/

Quick summary, since this thread never seems to have concluded.

string calls print (as documented here) which (by default) calls the 2-argument show (documented here, though it doesn’t say 2-arg specifically).

display (by default, in the REPL) calls the 3-argument show with text/plain which (by default) calls 2-argument show. Documented in the manual’s section on custom pretty-printing.

1-arg repr calls 2-arg show (documented here, though it doesn’t mention 2-arg specifically), and 2-arg repr (documented here) calls 3-arg show.

(This can all be overloaded, of course — one big exception to the above rules is for strings, in which case show and hence repr add quotation marks and backslash escaping of special characters, whereas print just outputs the raw string. This is mentioned in the print docs.)

The big omission from the docs is that the print and 1-arg repr functions just say that they call show, but should specifically say that they call the 2-argument show. I think this is because those functions pre-date the 3-arg show. PR to fix this omission: document that print(x) and repr(x) call 2-arg show by stevengj · Pull Request #53927 · JuliaLang/julia · GitHub

8 Likes