When overwriting Base.show for an Array of custom_type REPL eval() uses the old version of Base.show with only partial delegation/dispatch; which is cumbersome when working with large arrays of records in REPL.
Is this the expected behaviour, and there is a different approach to use REPL + eval + show or some sort of a exception I happened to stumble upon? any pointer/help is appreciated. [I am aware when wrapping arrays again in an object this can be avoided, but that requires implementing/dispatching methods Array{}() already has ] short self contained minimal example attached thanks, steve ------------------- CODE --------------- #!/usr/local/bin/julia # minimal working example to demonstrate that one is # unable to overwrite Base.show for Array{custom_type,1} when using REPL # # julia> versioninfo() # Julia Version 0.4.0-dev+2895 # Commit a37025e* (2015-01-25 09:20 UTC) #Platform Info: # System: Linux (x86_64-linux-gnu) # CPU: Intel(R) Core(TM) i7-3667U CPU @ 2.00GHz # WORD_SIZE: 64 # BLAS: libmkl_rt # LAPACK: libmkl_rt # LIBM: libimf # LLVM: libLLVM-3.3 # module repl_test import Base.show export show type A value::Int64 end show( io::IO, x::A ) = @printf(" A: %i\n", x.value ) show( io::IO, x::Array{A,1} ) = @printf(" A: many values\n" ) end x = repl_test.A( 5 ) show(x) # as advertised x # same as above # printout in REPL # A: 5 # A: many values y = Array(repl_test.A, 10) show(y) # still works as expected # julia> show(y) # A: many values ###### like io::IO, x::Array{A,1} = ... didn't exist y # julia> y # 10-element Array{repl_test.A,1}: # #undef # ... omitted # #undef # The above code when evaluated in REPL uses built in Base.show for array and indirectly # calls overwritten Base.show # I find it very cumbersome and unfriendly when unable to pretty print large arrays of structs # imported from other systems. # Is there a better/working solution to use the REPL similarly to when interacting with GNU R?
repl_show_test.jl
Description: Binary data