Maybe you can adapt this:
julia> type Outer{T}
A::T
B::T
end
julia> Outer{TT}(a::TT, b::TT) = Outer{TT}(a,b)
Outer{T}
## the first {TT} is a function type parameter whereas the second {TT}
## is the type parameter! Very confusing
julia> Outer(5,6)
Outer{Int64}(5,6)
Note that your last constructor suggests that your type may should look
like so:
type Outer{T}
a::A{T}
b::B{T}
end
But the gist of above should still work. I think there is a section on
this in the manual.
On Thu, 2016-01-21 at 15:23, [email protected] wrote:
> Hello,
> I have a problem to which I have found a dirty solution and I am keen to
> know, if there is a principal one.
>
> I have a composite type defined as
>
> type Outer{T}
> A::T
> B::T
> end
>
> where A and and B are composite types
>
> Then I want to create constructor
> function Outer(k::Int)
> return(Outer(A{T}(k),B{T}(k))
> end
>
> But I have not find a way to put there the type information.
> The only dirty hack I have come with to define the outer constructor as
>
> function Outer(k::Int;T::DataType=Float32)
> return(Outer(A{T}(k),B{T}(k))
> end
>
> But I do not like this solution too much. It is little awkward.
>
> Thanks for suggesting a cleaner solution.
>
> Best wishes,
> Tomas