Shouldn't it behave the opposite way?

Array{<:FloatingPoint}

representing an array composed of elements which are subtypes of 
FloatingPoint and

Array{FloatingPoint}

representing an array composed of elements of the exact same type which is 
a subtype of FloatingPoint?

Before implementing this great idea, a "<:Type" definition should be found 
as  JeffBezanson stressed on Github.

Le mardi 27 mai 2014 09:16:02 UTC+2, Toivo Henningsson a écrit :
>
> Great to hear such positive response :)
> I've created an issue for the feature request: 
> https://github.com/JuliaLang/julia/issues/6984
>
> On Monday, 26 May 2014 22:25:37 UTC+2, Adam Smith wrote:
>>
>> +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}) 
>>>>
>>>>

Reply via email to