I stumbled across this today while debugging a little macro I am writing. If someone could explain this to me, I would really appreciate it. It’s not a problem for my code, but I’m quite curious to understand.
My macro itself isn’t very relevant, but it parses its arguments and builds an array of Float64
s, then passes the transpose of this array as one of several parameters to a function in the returned expression. This is where I noticed the unexpected.
A minimal example to reproduce:
julia> a = [1.0]
1-element Vector{Float64}:
1.0
julia> a'
1×1 adjoint(::Vector{Float64}) with eltype Float64:
1.0
julia> transpose(a)
1×1 transpose(::Vector{Float64}) with eltype Float64:
1.0
julia> println("$(a)")
[1.0]
julia> println("$(a')")
[1.0;;] # Why the semi-colons???
julia> println("$(transpose(a))")
[1.0;;] # Why the semi-colons???
julia> b = [1.0, 2.0]
2-element Vector{Float64}:
1.0
2.0
julia> b'
1×2 adjoint(::Vector{Float64}) with eltype Float64:
1.0 2.0
julia> transpose(b)
1×2 transpose(::Vector{Float64}) with eltype Float64:
1.0 2.0
julia> println("$(b)")
[1.0, 2.0]
julia> println("$(b')")
[1.0 2.0] # No semi-colons here
julia> println("$(transpose(b))")
[1.0 2.0] # Or here
Why does the result for a
in the println()
s include the two semi-colons? There are no semi-colons if the original array contains more than one entry, as illustrated with the b
example.
It also doesn’t matter if I use the adjoint operator or the transpose function. It seems to be a result of the string interpolation, but only for the transpose/adjoint.