You're right, that's not bad at all. Thanks.

On Sunday, May 25, 2014 12:41:04 PM UTC-4, Iain Dunning wrote:
>
> julia> f{T<:String}(strs::Vector{T}) = dump(strs)
> f (generic function with 1 method)
>
> julia> f(["foo"])
> Array(ASCIIString,(1,)) ASCIIString["foo"]
>
>
> Seems fine to me, and more importantly (to me), is consistent and logical. 
> Vector{String} is a concrete type, its a specific thing. 
> Vector{T},T<:String, is the family of vectors that contain String-y things.
> Unless you are writing library code, not much point to getting trick with 
> type signatures anyway - there is no speed benefit to doing so, its just a 
> defensive programming thing.
>
>
> On Sunday, May 25, 2014 12:23:34 PM UTC-4, Adam Smith wrote:
>>
>> I'd just like to add that this behavior is a real downer when dealing 
>> with strings, too. During testing/debugging inline strings are 
>> ASCIIStrings, but I don't want to hardcode my functions to use ASCIIStrings 
>> (or have to make Unions absolutely every place I want a vector of strings):
>>
>> julia> f(strs::Vector{String}) = dump(strs)
>> f (generic function with 1 method)
>>
>> julia> f(["foo"])
>> ERROR: no method f(Array{ASCIIString,1})
>>
>> julia> g(strs::Vector{UTF8String}) = dump(strs)
>> g (generic function with 1 method)
>>
>> julia> g(["foo"])
>> ERROR: no method g(Array{ASCIIString,1})
>>
>> julia> h(strs::Vector{ASCIIString}) = dump(strs)
>> h (generic function with 1 method)
>>
>> julia> h(["foo"])
>> Array(ASCIIString,(1,)) ASCIIString["foo"]
>>
>>
>>
>> On Sunday, May 25, 2014 11:46:43 AM UTC-4, Pierre-Yves Gérardy wrote:
>>>
>>>
>>>
>>> On Sunday, May 25, 2014 5:44:26 PM 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
>>>>
>>>  
>>> ... or  Fp = FloatingPoint , types are first class objects.
>>>  
>>>
>>>>  
>>>>
>>> function foo{T1<:Fp, T2<:Fp}(a::Array{T1}, b::Array{T2}) 
>>>>
>>>>

Reply via email to