First of all, I’m still running v0.6.4 (-_-).
I’m specifically trying to write a subtype of AbstractArray with a non-standard data structure backing it. I’d like to override getindex specifically in the case of slices (e.g., index varargs containing either single integers or Colons), but I’m not sure what signature of getindex/setindex! I need to override.
base/abstractarray.jl says:
## Approach:
# We only define one fallback method on getindex for all argument types.
# That dispatches to an (inlined) internal _getindex function, where the goal is
# to transform the indices such that we can call the only getindex method that
# we require the type A{T,N} <: AbstractArray{T,N} to define; either:
# getindex(::A, ::Int) # if IndexStyle(A) == IndexLinear() OR
# getindex{T,N}(::A{T,N}, ::Vararg{Int, N}) # if IndexCartesian()
# If the subtype hasn't defined the required method, it falls back to the
# _getindex function again where an error is thrown to prevent stack overflows.
But supplying the second method only seems to net me scalar indexing. I’d even like full non-scalar multidimensional indexing.
I looked at StaticArrays.jl as well, but their getindex/setindex! functions are generated which has the side-effect of making it harder for me to read.
If someone could point me in the right direction, I’d greatly appreciate it.
EDIT: Just in case it’s unclear, I’d like the non-scalar getindex to return a CustomArray as well. The data structure stores some bookkeeping that I’d like to persist across slices.