On Thu, Jan 21, 2016 at 9:23 AM, <[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
call{T}(::Type{Outer{T}}, k::Int) = Outer(A{T}(k), B{T}(k))
Outer{Float64}(1)
Syntax might change again with jb/function
>
> 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
>