I’ve often thought that Array{T <: Any} would be easier to understand, so +1 
for this.

 — John

On May 26, 2014, at 12:33 PM, Toivo Henningsson <[email protected]> wrote:

> Or you can use
> 
>     typealias FPArray{T<:FloatingPoint} Array{T}
> 
>     foo(a::FPArray, b::FPArray) = a+b
> 
> to get the same effect (foo will still apply when the element types of a and 
> b are different).
> 
> Perhaps we could introduce a syntax to create such a covariant typealias on 
> the fly, e.g.
> 
>     const FPArray2 = Array{<:FloatingPoint}
> 
> would work the same as FPArray above (though with an anonymous/hidden type 
> parameter).
> Then the example could be written
> 
>     foo(a::Array{<:FloatingPoint}, b::Array{<:FloatingPoint}) = a+b
> 
> if you don't want to define the typealias first.
> 
> On Sunday, 25 May 2014 17:44:26 UTC+2, Pierre-Yves Gérardy wrote:
> On Sunday, May 25, 2014 5:10:49 PM UTC+2, James Crist wrote:
> Yeah, that's what I've been using. My issue with it is that the declarations 
> get long for functions with more than 2 arrays. Was hoping there was a more 
> concise way.
> 
> You can use  typealias Fp FloatingPoint , then
> 
> function foo{T1<:Fp, T2<:Fp}(a::Array{T1}, b::Array{T2}) 
> 

Reply via email to