CatViews.jl icon indicating copy to clipboard operation
CatViews.jl copied to clipboard

Parameter Ordering not consistent with AbstractArray

Open btmit opened this issue 4 years ago • 2 comments

To use CatView in my application, I need the following to be true:

CatView{Float64, 2} <: AbstractArray{Float64,2}

It looks like the parameter order is backwards compared to AbstractArray.

Would that be possible to fix?

Note that the following is true: CatView <: AbstractArray

btmit avatar Apr 09 '20 02:04 btmit

I have not looked closely at the code to see if there is a good reason not to do this (other than it being a breaking change).

But as a workaround you can define a type alias with what ever order you want.

e.g.

julia> abstract type AbstractFoo{X, Y} end

julia> struct Foo{Y, X} <: AbstractFoo{X, Y} end

julia> supertype(Foo{1,2})
AbstractFoo{2,1}

julia> const Bar{A, B} = Foo{B,A}
Foo{B,A} where B where A

julia> Bar{1,2}
Foo{2,1}

julia> Bar{1,2} <: AbstractFoo{1,2}
true

oxinabox avatar Apr 09 '20 07:04 oxinabox

That's a great workaround that will keep me going for now. Thanks!

btmit avatar Apr 09 '20 12:04 btmit