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... 

Reply via email to