# Reclaim parametric method syntax

**URL:** https://discourse.julialang.org/t/reclaim-parametric-method-syntax/7145
**Category:** General Usage
**Tags:** syntax
**Created:** [November 18, 2017, 4:52am UTC](https://discourse.julialang.org/t/reclaim-parametric-method-syntax/7145 "2017-11-18T04:52:59Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![lstagner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lstagner/32/448_2.png) [@lstagner](https://discourse.julialang.org/u/lstagner)
#### Post date: [November 18, 2017, 4:52am UTC](https://discourse.julialang.org/t/reclaim-parametric-method-syntax/7145/1 "2017-11-18T04:52:59Z")

</div>

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

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

```

as syntactic sugar for

```julia
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

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

```

---

<div class="post-metadata">

### Author: ![ssfrr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ssfrr/32/3736_2.png) [@ssfrr](https://discourse.julialang.org/u/ssfrr)
#### Post date: [November 18, 2017, 5:06am UTC](https://discourse.julialang.org/t/reclaim-parametric-method-syntax/7145/2 "2017-11-18T05:06:56Z")

</div>

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) = ...`

---

<div class="post-metadata">

### Author: ![lstagner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lstagner/32/448_2.png) [@lstagner](https://discourse.julialang.org/u/lstagner)
#### Post date: [November 18, 2017, 5:14am UTC](https://discourse.julialang.org/t/reclaim-parametric-method-syntax/7145/3 "2017-11-18T05:14:26Z")

</div>

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

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

```

---

<div class="post-metadata">

### Author: ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)
#### Post date: [November 18, 2017, 6:48pm UTC](https://discourse.julialang.org/t/reclaim-parametric-method-syntax/7145/4 "2017-11-18T18:48:45Z")

</div>

Edit: sorry I misunderstood something.

---

<div class="post-metadata">

### Author: ![Keno](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/keno/32/285_2.png) [@Keno](https://discourse.julialang.org/u/Keno)
#### Post date: [November 19, 2017, 7:56pm UTC](https://discourse.julialang.org/t/reclaim-parametric-method-syntax/7145/5 "2017-11-19T19:56:58Z")

</div>

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

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

```

---

<div class="post-metadata">

### Author: ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)
#### Post date: [November 20, 2017, 4:23am UTC](https://discourse.julialang.org/t/reclaim-parametric-method-syntax/7145/7 "2017-11-20T04:23:32Z")

</div>

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

---

<div class="post-metadata">

### Author: ![lstagner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lstagner/32/448_2.png) [@lstagner](https://discourse.julialang.org/u/lstagner)
#### Post date: [November 20, 2017, 10:24pm UTC](https://discourse.julialang.org/t/reclaim-parametric-method-syntax/7145/8 "2017-11-20T22:24:39Z")

</div>

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.
