Suppose I want to build a composite type
type X{A<:AbstractArray}
list::Vector{A}
individual::A
end
Now, al the elements of the list should be of some concrete type of
AbstractArray{T,N}, whereas individual is required to be of the same
concrete type of AbstractArray, have the same T, but can have a different
N'. So if all the elements in the list are Float64 Arrays, then so should
be individual. For AbstractArray this is less of an issue, since there are
not many concrete types with arbitrary N. In my code, it is not actually
the AbstractArray hierarchy that I am using, but some other hierarchy with
several concrete types.
So I was thinking of writing an outer constructor that accepts a general
list::Vector, does several consistency check, and tries to determine the
concrete subtype, but without fixing the N.
Op zaterdag 2 augustus 2014 19:06:02 UTC+2 schreef Leah Hanson:
>
> T{P1,P2,P3} is a family of types; each member specifies all three type
> parameters. There are no "super type" relationships within the family of T
> types; they are just all members of the same family (think "set") of types.
>
> Could you explain what you're trying to achieve? I don't think that making
> a type with only 2 of it's three parameters defined makes sense, so maybe
> we can find another way to achieve the same goal.
>
> -- Leah
>
>
> On Sat, Aug 2, 2014 at 6:37 AM, Jutho <[email protected] <javascript:>>
> wrote:
>
>> Suppose I have some type T{P1,P2,P3} depending some parameters. I don't
>> know which type exactly, except that it originates from a type hierarchy
>> which has 3 parameters. What is the best way to construct, given e.g. a
>> variable of type T{P1,P2,P3} with specific values for P1, P2, P3, to
>> construct the 'super' type T{P1,P2}. If TT = T{Float64,Float64,Float64}
>> then I know I could do TT.parameters = (TT.parameters[1],
>> TT.parameters[2], TypeVar(P3) ). But it turns out that is not yet
>> completely identical to T{Float64,Float64}, although TT==T{Float64,Float64}
>> and TT===T{Float64,Float64} evaluate to true. However, not all fields of TT
>> seem to be identical to those of T{Float64,Float64}. What is the
>> recommended strategy ? Is there a specific method for doing this?
>>
>>
>