No, this is wrong. The 1-argument show(x)
(which is also called by print(x)
for most types) calls the 2-argument show(stdout, x)
. For matrices, this is less verbose than the 3-argument show(stdout, "text/plain", x)
called by the REPL’s display
.
Summary:
display(x)
tells the current environment to displayx
in whatever way it thinks best. This might be a graphical display in something like a Jupyter notebook. By default (e.g. in scripts or in the text REPL), it callsshow(io, "text/plain", x)
or equivalentlyshow(io, MIME"text/plain"(), x)
for an appropriateio
stream. (In the REPL,io
is anIOContext
wrapper aroundstdout
.) The REPL usesdisplay
to output the result of an evaluated expression.- The 3-argument
show(io, ::MIME"text/plain", x)
method is verbose pretty-printing ofx
. By default (if no verbose method is defined fortypeof(x)
), it calls the 2-argumentshow(io, x)
. - The 2-argument
show(io, x)
is the default simple text representation ofx
. It is what is used byrepr(x)
, and is typically the format you might use to inputx
into Julia. The 1-argumentshow(x)
callsshow(stdout, x)
. print(x)
callsprint(stdout, x)
, which by default callsshow(stdout, x)
. It mainly differs fromshow
whenx
is a string, whereprint
outputs the raw text butshow
outputs an escaped string enclosed in quotation marks.
Update May 2024: a version of this summary should be added to the manual (julia#54547).