I might be wrong, but isn't that requirement (T===typeof(x)) strictly 
mandatory to make diagonal dispatch work? If I define

issametype{T}(x::T, y::T) = true
issametype(x,y) = false

in a world where isa(x,T) is enough, and then call

issametype(1, 1.0)

I would get true because Julia can compile a version with e.g. T == Number. 
I think the only non-breaking solution to this would be to make it possible 
to define type-arguments that depend on earlier type-arguments, such as 
your example unshift!{T, I<:T}(l::List{T}, i::I}. I would think such an 
enhancement was awesome, but I have no idea how difficult it would be to 
implement.

// Tomas


On Sunday, May 11, 2014 9:11:17 PM UTC+2, Toivo Henningsson wrote:
>
> I've only come to suspect this recently, but I believe that type 
> parameters have always been a special case such that if T is a type 
> parameter of a method, then x::T in the argument list requires that 
> T===typeof(x), not just isa(x, T) as otherwise. I guess that this is 
> deliberate, though I find it inconsistent and somewhat dissatisfying. 

Reply via email to