Ah, yep. I figured I might have to at least know the type ahead of time.
This should work though, thanks!!
Chris
On Friday, March 4, 2016 at 12:26:49 PM UTC-5, John Myles White wrote:
>
> Is this what you want?
>
>
> julia> abstract ABC
>
>
> julia> type A <: ABC end
>
>
> julia> type B <: ABC end
>
>
> julia>
>
>
> julia> type TestType{T <:ABC}
>
>a::Float64
>
>b::T
>
>
>
>TestType(a::Float64) = new(a)
>
>end
>
>
> julia> myT = TestType{A}(4.0)
>
> TestType{A}(4.0,#undef)
>
>
> julia> myT.b = A()
>
> A()
>
>
> julia> myT
>
> TestType{A}(4.0,A())
>
> On Friday, March 4, 2016 at 9:19:42 AM UTC-8, Christopher Alexander wrote:
>>
>> Hi all,
>>
>> Is there anyway to do something like the following?
>>
>> abstract ABC
>>
>> type A <: ABC end
>>
>> type B <: ABC end
>>
>> type TestType{T <:ABC}
>> a::Float64
>> b::T
>>
>> TestType(a::Float64) = new(a)
>> end
>>
>> myT = TestType(4.0)
>> myT.b = A()
>>
>> I am wondering if you can incompletely initialize a parametric type, and
>> then set the actual value needed later. The above code doesn't work, but
>> that is what I'm trying to do. The alternative is I guess to have some
>> default Null Type, but then to get the performance gains I have to copy the
>> object when I want to actually set it with the value that I want.
>>
>> Thanks!
>>
>> Chris
>>
>