# PSA: Parametric method syntax deprecation about to drop

**URL:** https://discourse.julialang.org/t/psa-parametric-method-syntax-deprecation-about-to-drop/4931
**Category:** Internals & Design
**Created:** [July 18, 2017, 3:02pm UTC](https://discourse.julialang.org/t/psa-parametric-method-syntax-deprecation-about-to-drop/4931 "2017-07-18T15:02:08Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![jeff.bezanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff.bezanson/32/48_2.png) [@jeff.bezanson](https://discourse.julialang.org/u/jeff.bezanson)
#### Post date: [July 18, 2017, 3:02pm UTC](https://discourse.julialang.org/t/psa-parametric-method-syntax-deprecation-about-to-drop/4931/1 "2017-07-18T15:02:08Z")

</div>

[https://github.com/JuliaLang/julia/pull/22834](https://github.com/JuliaLang/julia/pull/22834)

Just a heads up. In my estimation, this could very well be the single biggest source of deprecation warnings ever, and that’s saying something. If anyone has any final thoughts, now is the time.

---

<div class="post-metadata">

### Author: ![tkelman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkelman/32/692_2.png) [@tkelman](https://discourse.julialang.org/u/tkelman)
#### Post date: [July 18, 2017, 6:03pm UTC](https://discourse.julialang.org/t/psa-parametric-method-syntax-deprecation-about-to-drop/4931/2 "2017-07-18T18:03:04Z")

</div>

See [https://github.com/JuliaLang/julia/search?utf8=✓&q="where+syntax"&type=Commits](https://github.com/JuliaLang/julia/search?utf8=%E2%9C%93&q=%22where+syntax%22&type=Commits) for what transitioning Base over to the new syntax has looked like over the past several months.

---

<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: [July 18, 2017, 6:48pm UTC](https://discourse.julialang.org/t/psa-parametric-method-syntax-deprecation-about-to-drop/4931/3 "2017-07-18T18:48:29Z")

</div>

Yeah, this is going to be a bit painful. Apologies in advance, for not having a better syntax for this in the first place and thereby inflicting this on everyone. I posted over here about the motivation for the change:

> [@Anybody else find the new where syntax less than satisfactory?](https://discourse.julialang.org/t/anybody-else-find-the-new-where-syntax-less-than-satisfactory/4897/14):
>
> I explained the overall motivation for the where syntax in this StackOverflow answer: Partly quoting from there (with some clarifications and edits): Fundamentally, the problem with F{T}(args...) in Julia 0.5 and earlier is that the F{T} part is ambiguous – the parser knows what it means from the broader context, but its meaning depends heavily on that context. The fact that it can mean such different things is pretty confusing: In most contexts, F{T} means the parametric type F with type…

---

<div class="post-metadata">

### Author: ![tkelman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkelman/32/692_2.png) [@tkelman](https://discourse.julialang.org/u/tkelman)
#### Post date: [July 18, 2017, 7:00pm UTC](https://discourse.julialang.org/t/psa-parametric-method-syntax-deprecation-about-to-drop/4931/4 "2017-07-18T19:00:16Z")

</div>

I wonder whether a script could be written using Tokenize.jl and/or CSTParser.jl to try to automatically switch these over. Would probably be more complicated than the one for the type keywords from [https://github.com/JuliaLang/julia/pull/20418#issuecomment-277201589](https://github.com/JuliaLang/julia/pull/20418#issuecomment-277201589)

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [July 18, 2017, 7:24pm UTC](https://discourse.julialang.org/t/psa-parametric-method-syntax-deprecation-about-to-drop/4931/5 "2017-07-18T19:24:38Z")

</div>

Yes, I know CSTParser (@zacln) used to have a deprecation warning for that so at least CSTParser can detect it. Maaaybe writing a small script to do the transformation wouldnt be so hard.

---

<div class="post-metadata">

### Author: ![ZacLN](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zacln/32/2748_2.png) [@ZacLN](https://discourse.julialang.org/u/ZacLN)
#### Post date: [July 18, 2017, 8:35pm UTC](https://discourse.julialang.org/t/psa-parametric-method-syntax-deprecation-about-to-drop/4931/6 "2017-07-18T20:35:57Z")

</div>

The julia-vscode plugin detects this and has an automatic fix (click on hint region then on the lightbulb that pops up) for either single instances, or all within a file.

---

<div class="post-metadata">

### Author: ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)
#### Post date: [July 18, 2017, 8:42pm UTC](https://discourse.julialang.org/t/psa-parametric-method-syntax-deprecation-about-to-drop/4931/7 "2017-07-18T20:42:13Z")

</div>

I think you’re going to get a lot of new users because of that feature 🙂 .

---

<div class="post-metadata">

### Author: ![jeff.bezanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff.bezanson/32/48_2.png) [@jeff.bezanson](https://discourse.julialang.org/u/jeff.bezanson)
#### Post date: [July 18, 2017, 9:13pm UTC](https://discourse.julialang.org/t/psa-parametric-method-syntax-deprecation-about-to-drop/4931/8 "2017-07-18T21:13:16Z")

</div>

That is really amazing. Just clicking “like” on that post is not enough 🙂 I will now finally have to try vscode!

---

<div class="post-metadata">

### Author: ![tshort](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tshort/32/43_2.png) [@tshort](https://discourse.julialang.org/u/tshort)
#### Post date: [July 18, 2017, 9:24pm UTC](https://discourse.julialang.org/t/psa-parametric-method-syntax-deprecation-about-to-drop/4931/9 "2017-07-18T21:24:41Z")

</div>

Just tried it. Awesome! I’ve been using VS Code a while, but I missed this. I’ll have to watch the release notes from David and Zac more carefully.

---

<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: [July 24, 2017, 5:29pm UTC](https://discourse.julialang.org/t/psa-parametric-method-syntax-deprecation-about-to-drop/4931/10 "2017-07-24T17:29:02Z")

</div>

Would it be possible to extract that functionality into a standalone script to fix up Julia source files?

---

<div class="post-metadata">

### Author: ![randyzwitch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/randyzwitch/32/15955_2.png) [@randyzwitch](https://discourse.julialang.org/u/randyzwitch)
#### Post date: [July 24, 2017, 9:05pm UTC](https://discourse.julialang.org/t/psa-parametric-method-syntax-deprecation-about-to-drop/4931/11 "2017-07-24T21:05:00Z")

</div>

Just to be clear, this is “about to drop” in 0.7-master, not a 0.6 feature?

---

<div class="post-metadata">

### Author: ![jeff.bezanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff.bezanson/32/48_2.png) [@jeff.bezanson](https://discourse.julialang.org/u/jeff.bezanson)
#### Post date: [July 24, 2017, 9:05pm UTC](https://discourse.julialang.org/t/psa-parametric-method-syntax-deprecation-about-to-drop/4931/12 "2017-07-24T21:05:44Z")

</div>

Yes.

---

<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: [July 24, 2017, 10:02pm UTC](https://discourse.julialang.org/t/psa-parametric-method-syntax-deprecation-about-to-drop/4931/13 "2017-07-24T22:02:59Z")

</div>

Yes. We could also make a GitHub bot or integration of some sort.

---

<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: [July 24, 2017, 10:56pm UTC](https://discourse.julialang.org/t/psa-parametric-method-syntax-deprecation-about-to-drop/4931/14 "2017-07-24T22:56:29Z")

</div>

As Jeff said, yes, on 0.7-DEV – there will be no new features or breaking changes on 0.6.

---

<div class="post-metadata">

### Author: ![ZacLN](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zacln/32/2748_2.png) [@ZacLN](https://discourse.julialang.org/u/ZacLN)
#### Post date: [July 25, 2017, 8:05am UTC](https://discourse.julialang.org/t/psa-parametric-method-syntax-deprecation-about-to-drop/4931/15 "2017-07-25T08:05:38Z")

</div>

yup, [https://gist.github.com/ZacLN/2f0d66c651647e32eae85e58102315cb](https://gist.github.com/ZacLN/2f0d66c651647e32eae85e58102315cb)

`fixdep(filename, overwrite = false)`

EDIT: though without the full namespace scoping it can’t distinguish between function calls and type constructors

---

<div class="post-metadata">

### Author: ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)
#### Post date: [July 25, 2017, 4:50pm UTC](https://discourse.julialang.org/t/psa-parametric-method-syntax-deprecation-about-to-drop/4931/16 "2017-07-25T16:50:15Z")

</div>

I’m not convinced of this idea myself, but I thought I’d throw it out there.

To ease this exceptional deprecatastrophe, perhaps it would make sense to have a special 0.6.1 release halfway through the 0.6 life-cycle in which the _only_ change is this deprecation. This might make the transition easier on people since it won’t be accompanied by lots of other deprecations and errors. The alternative thinking is that it is better to resolve deprecations all at once, but in practice I’ve noticed that it sometimes takes them a long time to get fixed, so perhaps a staged approach is better.

---

<div class="post-metadata">

### Author: ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)
#### Post date: [July 25, 2017, 6:41pm UTC](https://discourse.julialang.org/t/psa-parametric-method-syntax-deprecation-about-to-drop/4931/17 "2017-07-25T18:41:55Z")

</div>

I think that 0.7 is largely serving that purpose by providing a smoother deprecation path to 1.0.

---

<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: [July 25, 2017, 9:09pm UTC](https://discourse.julialang.org/t/psa-parametric-method-syntax-deprecation-about-to-drop/4931/18 "2017-07-25T21:09:12Z")

</div>

I don’t think that making people update deprecations more times is helpful. It’s not all that hard to do, it’s just kind of annoying, so doing it fewer times is generally better.

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [July 25, 2017, 10:53pm UTC](https://discourse.julialang.org/t/psa-parametric-method-syntax-deprecation-about-to-drop/4931/19 "2017-07-25T22:53:38Z")

</div>

Here is a bit of an extension to the fixer by @ZacLN. It patches all the julia files in a package on a checked out branch, and makes a commit with the changes. Blam, ready for PR. I just did [https://github.com/JuliaStats/Distances.jl/pull/73](https://github.com/JuliaStats/Distances.jl/pull/73) with it.

```julia

function fixpkg(pkg::String, overwrite = false)
    !isdir(Pkg.dir(pkg)) && error("Did not find package directory")
    repo = LibGit2.GitRepo(Pkg.dir(pkg))    
    LibGit2.isdirty(repo) && error("Package repo is dirty")
    if overwrite
        info("Checking out branch fix_where")
        LibGit2.branch!(repo, "fix_where")
    end
    for (root, dirs, files) in walkdir(Pkg.dir(pkg))
        for file in files
            if endswith(file, ".jl")
                FixParameterisedFunctionDeprecation.fixdep(joinpath(root, file), overwrite)
                if overwrite
                    LibGit2.add!(repo, joinpath(root, split(root, Pkg.dir(pkg))[2]))
                end
            end
        end
    end
    overwrite && LibGit2.commit(repo, "fix deprecation warnings for new where syntax")
    return
end

```

---

<div class="post-metadata">

### Author: ![musm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/musm/32/3675_2.png) [@musm](https://discourse.julialang.org/u/musm)
#### Post date: [July 26, 2017, 12:11am UTC](https://discourse.julialang.org/t/psa-parametric-method-syntax-deprecation-about-to-drop/4931/20 "2017-07-26T00:11:59Z")

</div>

Is it possible to be consistent with the spaces, i.e. I would like it to remove spaces? E.g. `f{T<:Float32}(x::T) = T(2.0)` gets transformed to `f(x::T) where {T <: Float32} = x` instead of `f(x::T) where {T<:Float32} = x`

[Next page](https://discourse.julialang.org/t/psa-parametric-method-syntax-deprecation-about-to-drop/4931.md?page=2)
