I've answered my own question here: the key, for now, is to overload
writemime. However, it doesn't seem that should be necessary, so I've
commented on an existing GitHub issue
<https://github.com/JuliaLang/julia/issues/6117#issuecomment-50502411>
about it.
The #undef issue is *not my problem. *I am not interested in printing the
values *at all.*
On Tuesday, July 29, 2014 11:08:06 AM UTC-5, Michael Grant wrote:
>
> I have defined a subclass of AbstractArray for which I do *not* want to
> use the default AbstractArray printing machinery in show.jl . My
> assumption, apparently incorrect, is that I simply needed to overload show.
> Unfortunately, my overloaded version is never used.
>
> Here is some sample code. Note two things:
>
> - The code contained within a named module, and Base.Array is not
> imported, so there is not a name conflict here.
> - The function eleltype is indeed defined, and returns T. The actual
> eltype of this array is Scalar{T}. But the data is not stored as a
> contiguous memory buffer containing Scalar{T} objects; it has been
> compressed in a certain way.
>
> show(io::IO,x::Array) = print( io, "CVX $(eleltype(x)) $(ndims(x))D Array
> ..." )
> show{T,N}(io::IO,::Type{Array{T,N}}) = print( io, "CVX $(T) $(N)D Array" )
> show(io::IO,::Type{Array}) = print( io, "CVX Array" )
>
> The last two lines work as expected, suggesting I'm indeed exporting if I
> type CVX.Array or CVX.Array{Float64,2} into the REPL, my custom show
> commands are called. But if I attempt to instantiate an instance, and show
> that, it still calls the show.jl code; my overloaded version is ignored.
> Here's what I get:
>
> 2x2 Array{Float64,2}:
> #undef #undef
> #undef #undef
>
> And here is the output of an explicit call to show(A)
>
> CVX Float64 2D Array ...
>
> I tried modifying that first line as follows
>
> show{T,N}(io::IO,x::Array{T,N}) = print( io, "CVX $(T) $(N)D Array ..." )
>
> but that didn't make a difference. I tried different combinations of
> import/export
> show as well. As you probably know I do have to import it, but I don't
> have to export (at least, I don't think so), since I'm overloading. I also
> tried overloading print as well.
>
> Any hints? Thanks in advance for the help. I'm using Julia 0.3rc1 on the
> Mac...
>
>