Reclaim parametric method syntax

syntax

#1

Since the new where syntax has depreciated the parametric method syntax that means it can be used for something else. I propose the following

foo{T::Number}(x::T,y::T} = ...

as syntactic sugar for

let T=Number
    foo(x::T,y::T) = ...
end

This syntax can be very helpful when you have many variables with the same abstract type (especially if the abstract type has a long name).

Note that this is different than the familiar the foo(x::T,y::T) where T <: Number syntax
This lets T be a certain type and not just a subtype of one. For instance in the proposed syntax foo(1, 1.0) would work.

Edit:
Alternatively, a syntax that tells what a type is that wouldn’t use the parametric method syntax could be

foo(x::T,y::T) where T::Number = ...

#2

I have to say I’m not a big fan. I think that parametric types and methods are confusing enough without another subtly-different way to use similar syntax. The where changes helped a lot with matching up the way methods are defined with the way they’re called, which I think was a big improvement, and this would feel like a step backwards in simplicity and clarity. I don’t think the convenience here is worth the confusion, I’d rather just see (x::Number, y::Number, z::Number) = ...


#3

Perhaps an alternative syntax that wouldn’t use the parametric method syntax could be

foo(x::T,y::T) where T::Number = ...

#4

Edit: sorry I misunderstood something.


#5

The old parameteric syntax is not available for re-use, it now always means type application, e.g.

Complex{Int64}(a, b) = ...

#7

Why wouldn’t you just use the let syntax? That seems obvious and already works.


#8

I just think that it would be a nice syntactic feature. Also I think that suggested f(x::T,y::T) where T::Number = ... is a natural extension to the where syntax.