Oh cool! I was worried, since my call method was passing in the abstract
type if none was specified (ie I wasn't setting a value for the param "a"),
that it would just be the same as if I hadn't used a parametric type at all
and just set the type of "a" to the abstract type.
Thanks!
Chris
On Thursday, February 4, 2016 at 11:50:07 AM UTC-5, Kevin Squire wrote:
>
> No, `a` is the (concrete) type `T`, which is a subtype of `ABC` (and a new
> type `B{T}` is created for each `T`). So you shouldn't lose performance
> because of this.
>
> Cheers,
> Kevin
>
> On Thu, Feb 4, 2016 at 8:10 AM, Christopher Alexander <[email protected]
> <javascript:>> wrote:
>
>> Let's say I have the following types:
>>
>> abstract ABC
>>
>> type A <: ABC
>> a::Float64
>> end
>>
>> type B{T <: ABC}
>> a::T
>> end
>>
>> In some cases, I need for type "B" to be incompletely initialized so that
>> I can define its parameter "a" later. I've found out that you can do
>> something like this:
>>
>> type B{T <: ABC}
>> a::T
>>
>> call(::Type{B}) = new{ABC}()
>> end
>>
>> which then allows this:
>>
>> julia> myB = B()
>> B{ABC}(#undef)
>>
>> My question is, I'm assuming you lose any of the performance gain by
>> using the parametric type in this case because you are still using the
>> abstract type "ABC" for the parameter "a" (even if you define it later with
>> a concrete "A"). Is there a better way to do this?
>>
>> Thanks!
>>
>> Chris
>>
>
>