Keyword argument name same as variable name: Short hand notation

I think it was a change from v0.6 to 1.0 that we use ; for extra named keyword arguments. Now I’m thinking this can be used to achieve some short hand notation similar to this: ECMAScript 6 and Object Literal Property Value Shorthand · ariya.io in Javascript.

What I mean in particular:

julia> function test(a,b; extra=1)
       return a+b+extra
       end
test (generic function with 1 method)

julia> extra = 2
2

julia> test(2,3;extra)
ERROR: syntax: invalid keyword argument syntax "extra"

julia> test(2,3;extra=extra)
7

I think the shorthand notation would be a nice touch to shorten some function calls and when using the ; as a separator there is no other meaning possible in my opinion.
What do you guys think? :wink:

Yep, a popular request. Issue https://github.com/JuliaLang/julia/issues/29333

The ; thing is not new in 1.0 though.

4 Likes