You need to implement the minimal array interface.
Something along these lines:
length(c::Cube) = length(c.data)
eltype{T,N}(c::Cube{T,N}) = T
ndims{T,N}(c::Cube{T,N}) = N
size(c::Cube) = size(c.data)
size((c::Cube, i::Integer) = size(c.data, i)
Am Samstag, 25. April 2015 13:50:52 UTC+2 schrieb Marcus Appelros:
>
> Consider the definitions:
>
> type Cubes<:AbstractArray
> end
> sum(cubes::Cubes)=sum(convert(Array,cubes).^3)
>
> Is it possible to make this work? To create a custom array that has
> indexing and all at inception? Looked up the definition of Array and it is
> in the commented section on types implemented in C, its constructor is a
> ccall, if it isn't possible in pure julia would it be possible with C-code
> that doesn't prompt a rebuild?
>