# Why not always keyword?

**URL:** <https://discourse.julialang.org/t/why-not-always-keyword/10600>\
**Category:** Internals & Design\
**Created:** [April 28, 2018, 7:14pm UTC](https://discourse.julialang.org/t/why-not-always-keyword/10600 "2018-04-28T19:14:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![foobar\_lv2](https://avatars.discourse-cdn.com/v4/letter/f/ee59a6/32.png) [@foobar\_lv2](https://discourse.julialang.org/u/foobar_lv2)\
**Post date:** [April 28, 2018, 7:14pm UTC](https://discourse.julialang.org/t/why-not-always-keyword/10600/1 "2018-04-28T19:14:54Z")

</div>

Now that keyword arguments are becoming faster, I was wondering: Why not allow calling positional arguments with keywords? In cases that are not entirely inferred, keyword calling would of course be slower.

The only semantic problem I see are situations like:

```julia
f(x;y) = something(x,y)
f(x,y) = something_else(x,y)

```

The second definition recently became valid in [https://github.com/JuliaLang/julia/pull/25830](https://github.com/JuliaLang/julia/pull/25830).  
These methods are currently non-overlapping. If positional arguments became also keyword arguments, then the second version would overwrite the first. So this would definitely be very breaking in theory, but I don’t think it would be very breaking in practice.

Code that uses names for positional arguments that overlap with keyword-args of different methods are not good style: the names of positional parameters are readily available from the method table, and should serve as minimal documentation, i.e. are almost part of the API already. I am not sure whether there are technical problems with this (new feature would slow down dispatch even if not used?). Has there been a discussion of this approach already?

Python example for how I would imagine things to work out:

```julia
>>> def foo(xx, yy):
... print(xx,yy)
... 
>>> foo(3,4)
3 4
>>> foo(yy=4,xx=3)
3 4
>>> foo(3,yy=4)
3 4
>>> foo(xx=3, 4)
  File "<stdin>", line 1
SyntaxError: positional argument follows keyword argument

```

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [April 28, 2018, 7:33pm UTC](https://discourse.julialang.org/t/why-not-always-keyword/10600/2 "2018-04-28T19:33:55Z")

</div>

See [Allow use of named-argument syntax for positional arguments?](https://discourse.julialang.org/t/allow-use-of-named-argument-syntax-for-positional-arguments/5287)

---

<div class="post-metadata">

**Author:** ![foobar\_lv2](https://avatars.discourse-cdn.com/v4/letter/f/ee59a6/32.png) [@foobar\_lv2](https://discourse.julialang.org/u/foobar_lv2)\
**Post date:** [April 28, 2018, 7:46pm UTC](https://discourse.julialang.org/t/why-not-always-keyword/10600/3 "2018-04-28T19:46:53Z")

</div>

Thanks! Sorry for failing to find this in the archives.

DNF’s point about library authors not wanting to commit on naming makes a lot of sense, imho, as well as his final proposal for mature libraries that are willing to commit to argument names as part of the API, as base / stdlib might eventually do.
