T <: T question

question
documentation

#1

Does the example below from Types chapter of Julia manual depend on Real <: Real being true? I’m assuming that author’s intention was to include the first definition of norm in more generic definition, which follows.

Since Point{Float64} is not a subtype of Point{Real}, the following method can’t be applied to arguments of type Point{Float64}:

function norm(p::Point{Real})
   sqrt(p.x^2 + p.y^2)
end

The correct way to define a method that accepts all arguments of type Point{T} where T is a subtype of Real is:

function norm{T<:Real}(p::Point{T})
   sqrt(p.x^2 + p.y^2)
end

#2

What depend on that? It does “depend” on that being true so that the second signature is a strict superset of the first one though it’s a little weird since T<:T being true is a fundamental property of the type system that’s much more important than handling this special case that isn’t very important…


#3

That’s what I wanted to know. By depend I meant the narrative and the line of reasoning in that paragraph of Julia’s manual. It wasn’t clear to me as I’m just beginning with Julia. I should have worded my question more precisely.