I am trying to organize printing for a set of types the following way: a generic function returns a string representation, then
show for the supertype just prints it. MWE:
abstract type MyAbstractFun <: Function end Base.show(io::IO, f::MyAbstractFun) = println(io, representation(f)) struct One <: MyAbstractFun end (::One)(x) = x+1 representation(::One) = "just adds one"
but then evaluating at the REPL (ie going through
display) gives me the standard printing from
show works correctly:
julia> One() (::One) (generic function with 1 method) julia> show(One()) just adds one
Is this a bug, or am I doing something wrong?