This has certainly been proposed. See #15820 Define macro @display
and the discussion thread How to print arrays inside functions? - #5 by antoine-levitt … it wouldn’t be crazy to add something like this, but no one has done it yet.
See also #22253 Use multi-line format in @show
which at one point changed @show
to use a display
-like format, but this was subsequently reverted in #25849 because it broke the repr
property that you could cut-and-paste @show
results into code.
You could always define your own macro based on the code in #22253, of course:
macro myshow(exs...)
blk = Expr(:block)
for ex in exs
push!(blk.args, :(print($(sprint(Base.show_unquoted,ex)*" = "))))
push!(blk.args, :(show(stdout, "text/plain", begin value=$(esc(ex)) end)))
push!(blk.args, :(println()))
end
isempty(exs) || push!(blk.args, :value)
return blk
end
which gives
julia> @show rand(5);
rand(5) = [0.15242788991869327, 0.822593384182898, 0.24466669272136954, 0.9124861334431887, 0.6474094076037362]
julia> @myshow rand(5);
rand(5) = 5-element Vector{Float64}:
0.2430428495428918
0.556988929839062
0.9504355130227148
0.07313670570961417
0.7135984118032906