The reason you're needing to define more methods than the interface chapter 
suggests is because you haven't specified the AbstractArray's parameters; 
this is just as important as the required methods.  That is, you need to 
define your type as

type MyArr{T,N} <: AbstractArray{T,N}

in order for the interface to be properly defined.  This could be better 
emphasized in the interfaces chapter.

I'm not entirely sure what your needs are — could you clarify your use 
case?  Your wording makes it sound like you want the ability to dynamically 
change the dimensionality of the array at runtime.  Unfortunately, *many* 
of the builtin methods for AbstractArrays depend upon the dimensionality 
being defined as a type parameter… and therefore constant for each object. 
 Without that, you'll hit tons of missing methods that you'll need to 
implement on your own (as you've experienced).

Matt

On Thursday, September 10, 2015 at 3:06:45 AM UTC-4, Leonardo wrote:
>
> Hi All,
> I need some clarifications about subclassing AbstractArray to create a 
> multi-dimensional array with unspecified number of dimensions.
>
> I've created an (useless) example defining a simple container (attached) 
> to clarify me necessary step and function to implement, and then my doubts:
>
>    - for Julia 0.4.x a chapter *Interface* 
>    <http://docs.julialang.org/en/release-0.4/manual/interfaces/>states 
>    that minimal function that I MUST create are size(), getindex(), 
>    setindex!(), but in my case I MUST create another form of getindex(), 
>    setindex!() listed between optional methods
>    - for Julia 0.3.x previous chapter doesn't exists, then I don't have a 
>    clear guideline to implement my type
>    - running attached example (in Julia 0.3.11 64bit under Win7 64bit), 
>    other function are required to show objects in REPL (some also 
> undocumented 
>    like print_matrix() ), otherwise creation of an object (e.g. with 
>    command a = MyArr(3)) fails
>    
> Than, what's correct way to subclass AbstractArray for my needs 
> (multidimensional array)? 
>
>
> Many thanks in advance for anyone can indicate me right direction
>
>
> Leonardo
>
>
>

Reply via email to