Hi! I spent some time today reading the upcoming 0.6 documentation and had a few questions while trying to understand the upcoming new syntax for parametric types.

What is the difference, if any, between typealias Vector{T} Array{T,1} and const Vector = Array{T, 1} where T?

Of the following two forms, why can you say b). but not a).?

a). Tuple{X, Y} where X <: Real where Y <: Vector{X}

b). Tuple{X, Y} where Y <: Vector{X} where X <: Real

What is the difference, if any, between f{T}(x::T) = x and f(x::T) where T = x?

In another word B can use typevar in C (or in general any typevar defined later in syntactic order) but not the other way around. If B and C do not reference each other, the order can be reversed but itâ€™s not possible in general when they are referencing each other as in this case.

None. Except that the former might be getting deprecated due to conflict with a better constructor definition syntax.

Since most of us expect where to introduce a clause (i.e. a nontrivial expression) perhaps a better keyword would be something like for_any. These seem less confusing than the where versions, at least to me:

f(x::T) for_any T = x
t(x::T) for_any T = T
foo{T}(x) for_any T = rhs

And this is about the same (since type assertions are already peculiar):

Because itâ€™s f(t::(T where T))::T = ... which is f(t::Any)::T = .... The type parameter for the method has to be on the method, it is not if you put it into the argument. The thing before where is the thing thatâ€™s parametrized. For f(::T where T) itâ€™s T and for f(::T) where T itâ€™s f(::T). You want the latter for parametric method definition.

Yes, it constrains the first argument to be a pair with the same type, and a vector that has another type.
In that form, the Ts in each argument are independent. (g(x::Pair{T,T}, a::Array{T,1}) where T) = x, a is what you need to constrain the elements of the Pair and of the Vector to all be the same type.

anyone cares to explain what is the problem with this?

f(t::T where T)::T = ...

The parameter names of UnionAll types do not escape the signature. They do not automatically come into scope; they are inside the type. In your first example T is just a dummy variable used to discuss the type (T where T) which (I think) is converted to Any.

When the where is outside the signature, that indicates that the method is to be parameterized and the names of the type variables are visible both inside the signature and inside the method body (the ...).

The thing which â€śmightâ€ť make sense is

(f(t::T) where T)::T = ...

which is quite analogous to the allowed

(f(t::T) where T) = ...

given that (as I understand) the method output restriction ::T piece is transformed to be a part of the ... anyway.