Dear julia users/developers,

I am working on some toolbox for working with tensors (on a more rigorous 
level, defined as elements of tensor products of vector spaces; see 
https://github.com/Jutho/TensorToolbox.jl ), where the first few lines of a 
new type hierarchy start as follows:

abstract AbstractTensor{S<:IndexSpace,T,N}
Base.eltype{S,T}(::AbstractTensor{S,T}) = T
Base.eltype{S,T,N}(::Type{AbstractTensor{S,T,N}}) = T
Base.eltype{TT<:AbstractTensor}(::Type{TT}) = eltype(super(TT))
spacetype{S}(::AbstractTensor{S})=S
spacetype{S,T,N}(::Type{AbstractTensor{S,T,N}})=S
spacetype{TT<:AbstractTensor}(::Type{TT})=spacetype(super(TT))

similar to some of the first lines in abstractarray.jl. The only difference 
is that there is an extra parameter. In the method table (methods(eltype) 
or methods(spacetype)) the order of the methods on line 3 and 4 (for 
eltype) and of line 6 and 7 (for spacetype) is reversed. As a consequence, 
@which eltype(AbstractTensor{ComplexSpace,Float64,3})
is caught by line 4 instead of line 3, and returns Any, whereas clearly 
this should be Float64. Is there anything I do not understand of how this 
works for AbstractArray and that I am doing differently, or should I file 
an issue? Is there a way to force the order in which methods are added to 
the method table?

Thanks,

Jutho

Reply via email to