+1 to Toivo's idea. I LOVE that suggestion. Combine that with this, and
function declarations can fit on one line again:
typealias Float FloatingPoint
On Monday, May 26, 2014 3:33:38 PM UTC-4, Toivo Henningsson 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 aand
> 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})
>>
>>