> For the purposes of readability, is there any syntax by which I can avoid
> explicit parameterisation of the function? I am thinking of something like
> this:
>
> function fun(arr::Array{<:Type3, 1})
> end

No, there is none but it has been discussed
https://github.com/JuliaLang/julia/issues/6984.  But function signatures
may change quite a bit in the near future anyway, see for instance:
https://github.com/JuliaLang/julia/issues/11310#issuecomment-170421099

> S.
>
> On Tuesday, 2 February 2016 06:27:10 UTC, Mauro wrote:
>>
>> On Mon, 2016-02-01 at 18:29, Samuel Powell <s...@samuelpowell.co.uk
>> <javascript:>> wrote:
>> > Hi,
>> >
>> > Consider the following:
>> >
>> > abstract TypeA
>> >
>> > type Type1 <: TypeA
>> > end
>> >
>> > type Type2 <: TypeA
>> > end
>> >
>> > type Type3{T<:TypeA}
>> > prof::T
>> > end
>> >
>> > function fun(arr::Array{Type3, 1})
>> > end
>> >
>> > t1 = Type1()
>> > t2 = Type2()
>> >
>> > t3_1 = Type3(t1)
>> > t3_2 = Type3(t2)
>> >
>> > fun([t3_1; t3_2]) # This is fine
>> > fun([t3_1; t3_1]) # This fails with a no method error
>> > fun([t3_2; t3_2]) # This fails with a no method error
>>
>> This is because of invariance (search the doc or julia-users for it):
>>
>> julia> Array{Type3{Type1}}<:Array{Type3}
>> false
>>
>> This works:
>>
>> julia> function fun{T<:Type3}(arr::Array{T, 1})
>>        end
>> fun (generic function with 2 methods)
>>
>> julia> fun([t3_1; t3_1])
>>

Reply via email to