Thanks, Mauro. That's exactly what I needed.
On Wednesday, November 19, 2014 2:17:45 AM UTC-7, Mauro wrote:
>
> > immutable Foo{T,M,N} # probably want an immutable here, so nobody swaps
> > # out the arrays behind your back.
> > x::Array{T,M}
> > y::Array{T,N}
> > function Foo(x,y)
> > @assert (M + 1) == N
> > new(x,y)
> > end
> > end
> > Foo{T, M, N}(x::Array{T,M}, y::Array{T,N}) = Foo{T, M, N}(x,y)
> > Foo(rand(3),rand(3,2))
> > Foo(rand(3),rand(3,2,3)) # errors
>
> Also, the way outer and inner constructors of parameterized types are
> done is confusing many, including myself. Search the mailing list...
>
> Basically read the outer constructor
>
> Foo{T, M, N}(x::Array{T,M}, y::Array{T,N}) = Foo{T, M, N}(x,y)
>
> as: define a parameterized function Foo which calls a type constructor
> of the concrete type Foo{T,M,N}. The confusing thing is that both the
> function parameters and type parameters are the same and the function
> name and type name are the same. Which, of course, leads to brain-aches.
>