Sorry if this is a silly question but I don’t recall @show displaying spurious information like the following illustrates. Is that really the intended behavior?
The π example is a bit goofy, but there’s nothing really wrong going on here. @show x always prints x = and then whatever Base.repr(x) returns. It also returns the value of x, which the REPL then happily displays for you. You can see that with macroexpand:
julia> @macroexpand @show x
quote
(Base.println)("x = ", (Base.repr)(begin # show.jl, line 243:
#2#value = x
end))
#2#value
end
Base.repr(π) is "π = 3.1415926535897...", presumably to indicate that this is (a) indeed the pi which is approximately 3.14 and not some other pi but also (b) not a floating-point approximation but a representation of the exact number. It just looks goofy when you do @show pi for the same reason that @show 2 looks odd.
@show is used when you want to show both a value and the name of the variable it’s bound to. If that’s not what you want, then println() is probably the right choice.
@show is not particularly useful at the REPL. It’s meant to be used inside a block of code where just printing a value is less helpful than also showing what variable it’s bound to.
<code here>
@show a
<more code>
@show b
makes it obvious which of the printed values is a and which is b.