# Naming positional arguments at call site

**URL:** <https://discourse.julialang.org/t/naming-positional-arguments-at-call-site/103526>\
**Category:** Internals & Design\
**Created:** [September 4, 2023, 7:07pm UTC](https://discourse.julialang.org/t/naming-positional-arguments-at-call-site/103526 "2023-09-04T19:07:20Z")\
**Posts on this page:** 1\
**Showing post:** 39

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [September 4, 2023, 9:18pm UTC](https://discourse.julialang.org/t/naming-positional-arguments-at-call-site/103526/39 "2023-09-04T21:18:51Z")

</div>

> [@What steps should the Julia community take to bring Julia to the next level of popularity?](https://discourse.julialang.org/t/what-steps-should-the-julia-community-take-to-bring-julia-to-the-next-level-of-popularity/101389/604):
>
> The inability to use positional arguments with keywords

> [@ParadaCarleton](#):
>
> The compiler could handle it easily (see KeywordCalls.jl, which gives 0-cost keyword dispatch). The fact that keywords force runtime dispatch is because of a heuristic in the Julia compiler

I’ve tackled this before (and so have a lot of other much smarter people), and no, using keywords to specify positional arguments out of order really relies on a function having 1 method for each unique set of names. Simple example:

```julia
foo(a::Int, b::Float64) = a+b
foo(b::Float64, a::Int) = b-a
@keywordedpositional foo(b=1.5, a=2) # ambiguity error

```

KeywordCalls.jl doesn’t do an error in such a case, it uses the position of the keywords, which defeats the purpose of using keywords to shuffle positional arguments and adds an undesired layer of complexity to dispatch (`f(::Int, ::Int)` type signature not enough, needs additional keywords to determine which 1 of 2 methods).

```julia
# Adapting front page example to have >1 method for arguments (a,b)
using KeywordCalls
f(nt::NamedTuple{(:b, :a)}) = println("Calling f(b = ", nt.b,",a = ", nt.a, ")")
f(nt::NamedTuple{(:a, :b)}) = println("Calling f(a = ", nt.a,",b = ", nt.b, ")")
@kwcall f(b,a) # writing f(a, b) makes no difference here
#^ but if only 1 method exists, the order should match that method

f(a=1,b=2) # Calling f(a = 1,b = 2)
f(b=2,a=1) # Calling f(b = 2,a = 1)

```

---

_[View the full topic](https://discourse.julialang.org/t/naming-positional-arguments-at-call-site/103526)._
