Keyword arguments without a keyword?

That goes in the right direction. I think the body of the first map can be moved to a resolve_kw function and that function can be reused in the second map. This way fancy cases like (;a=1, b, more...) are handled better.

I just noticed that AtBackslash.jl (my unregistered package) already supports it:

julia> using AtBackslash

julia> f(; kwargs...) = (; kwargs...)
f (generic function with 1 method)

julia> let x = 1
           # input `()` is ignored
           () |> @\ f(; x)
(x = 1,)

julia> (x = 1, y = 2) |> @\ f(; :x, a = :y)  # more real-world usecase
(x = 1, a = 2)

(This is only relevant for anonymous functions, though.)

Julia’s AST is very well-designed so that you can accidentally implement features :slight_smile:


Registration is in progress.