0
votes

Say I enter:

julia> X = randn(3,4)
3x4 Array{Float64,2}:
 -0.862092   0.78568     0.140078  -0.0409951
 -0.157692   0.0838577   1.38264   -0.296809 
  1.40242   -0.628556   -0.500275   0.258898 

What functions were called to produce the output given?

Note that overloading Base.show does not seem to be sufficient to change this behaviour, so I'm unsure where to go.

julia> Base.show(io::IO, A::Array{Float64, 2}) = println("Humbug")
show (generic function with 120 methods)

julia> X
3x4 Array{Float64,2}:
 -0.862092   0.78568     0.140078  -0.0409951
 -0.157692   0.0838577   1.38264   -0.296809 
  1.40242   -0.628556   -0.500275   0.258898 

Is it perhaps the case that I would have to change Base/array.jl source code and rebuild julia before such a change would work? Note the difference between this and a user defined type:

julia> type foo
       x::Float32
       s::ASCIIString
       end

julia> ob = foo(1., "boo")
foo(1.0f0,"boo")

julia> Base.show(io::IO, someob::foo) = print("Humbug!")
show (generic function with 123 methods)

julia> ob
Humbug!
1
Base.show(X) will give you the Humbug. :)Gnimuc

1 Answers

4
votes

well, you should overload display():

julia> Base.display(A::Array{Float64, 2}) = println("Humbug")
display (generic function with 11 methods)

julia> X
Humbug

you can find the definition in REPL.jl.