Thanks a lot, Tim, your answer is extremely clear. I'll do some tests with 
both solutions to decide which one I like most.

Cheers,
  Maurizio.

On Thursday, September 10, 2015 at 5:39:29 PM UTC+2, Tim Wheeler wrote:
>
> Julia only supports concrete leaves in the type tree - all non-leaves 
> (parents) must be abstract types.
>
> You should be able to do:
>
> abstract AbstractDataStream{T <: Number}
>
> type DirectedDataStream{T <: Number} <: AbstractDataStream{T}
>     data::Vector{T}
>     stuff
> end
>
> type ReversedDataStream{T <: Number} <: AbstractDataStream{T}
>     data::Vector{T}
>     stuff
> end
>
> Another thing you can do that still leverages multiple dispatch is define 
> the reversal as a separate type:
>
> abstract Direction
> type ForwardDirection <: Direction end
> type BackwardDirection <: Direction end
>
> type MyDataStream{T<:Number, D<:Direction}
>     data::Vector{T}
>     direction::D
>     stuff
> end
>
> Base.plus{T<:Number, S<:Number, D<:ForwardDirection}(a::MyDataStream{T,D}, 
> b::MyDataStream{S,D}) ...
> Base.plus{T<:Number, S<:Number, D<:BackwardDirection}(a::MyDataStream{T,D
> }, b::MyDataStream{S,D}) ...
>
>
>

Reply via email to