Regular expression (regex) for updating to `where` syntax

I thought the following would be useful for those updating packages to 0.7, which has deprecated the old syntax f{T}(x::T) in favour of using where f(x::T) where T. These are two regular expressions that I use in Atom’s search field, where the first line is what is searched for and the second line the replacement rule:

([^{\n(]*)(\{[^\n}]*\})\(([^\n]*)=
$1($3where $2 =
function ([^{\n(]*)(\{[^\n}]*\})\(([^\n]*)\n
function $1($3 where $2\n

These are not perfect, so I suggest checking the replacement one at a time.

1 Like

PSA: Parametric method syntax deprecation about to drop - #15 by ZacLN also has some nice stuff

2 Likes