I don't think that's type-stable. Since each node of each tree will also be a
different type, I also think you'll end up hating life due to compile times.
There's some (peripherally) relevant discussion at http://docs.julialang.org/
en/latest/manual/performance-tips/#the-dangers-of-abusing-multiple-dispatch-
aka-more-on-types-with-values-as-parameters
Best,
--Tim
On Tuesday, August 23, 2016 3:28:17 PM CDT Ben Ward wrote:
> I'm doing some development and wondered if this kind of pattern is
> problematic:
>
> abstract AbstractNode
> abstract PhylogenyNode <: AbstractNode
> abstract NetworkNode <: AbstractNode
> abstract AbstractEdge
> abstract PhylogenyEdge <: AbstractEdge
> abstract NetworkEdge <: AbstractEdge
>
> type Branch{N <: PhylogenyNode} <: PhylogenyEdge
> from::N{Branch}
> to::N{Branch}
> length::Float64
>
> function Branch{N}(::Type{N})
> x = new()
> length!(x, -1.0)
> return x
> end
> end
>
> type Clade{E <: PhylogenyEdge} <: PhylogenyNode
> from::E
> to::Vector{E}
> confidence::Float64
>
> function Clade{E}(::Type{E})
> x = new()
> x.to = Vector{E}()
> confidence!(x, -1.0)
> return x
> end
> end
>
>
>
> As you can see both concrete types are parametric, and as a result there is
> a certain circularity to it
> Clade{Branch{Clade{Branch{Clade{Branch}}}}}.... That ultimately ends in
> something like Clade{Branch{N<:PhylogenyNode}}. I'd like to know if this is
> type-certain or not - the fact it terminates in N<:PhylogenyNode or
> E<:PhylogenyEdge makes me doubt it.