Le vendredi 29 avril 2016 à 00:06 -0700, DNF a écrit :
> I was going to suggest:
>
> type MyType{A<:AbstractArray, T<:Unsigned}
> data::A{T}
> end
>
> which does not work. The error is:
> ERROR: TypeError: Type{...} expression: expected Type{T}, got TypeVar
>
> Does anyone know whether this should work in an ideal world, or does
> the type definition simply not make sense?
This is called triangular dispatch, and will likely be supported at
some point. See https://github.com/JuliaLang/julia/issues/3766 and the
issues linked there.
Regards
> > Hi, I'm tying to create a parametric type which can hold a variable
> > which could be any kind of vector, and whatever the vector is, it
> > can store one of the UInts. So it could have:
> >
> > UInt8[1,2,3]
> > UInt64[1,2,3]
> > UnitRange(1, 3)
> > UnitRange(UInt16(1), UInt16(3))
> > ... and so on.
> >
> > But I'm having trouble deciding what needs to go in the parametric
> > part of it's definition: e.g.
> >
> > MyType{T <: (unsure of this bit)}
> > val::T
> > end
> >
> >
> > I thought that AbstractVector{Unsigned} might be the way to go, but
> > Vector{UInt8} does not inherit from AbstractVector{Unsigned}.
> >
> > Thanks,
> > Ben.
> >