Unpacking a named tuple using field names and slurping?

You could use a macro.

julia> macro alajs(e)
           pos=findfirst(el -> startswith(string(el),string(e.args[1].args[1])), e.args[2].args)
           e.args[2].args[pos], e.args[2].args[1] = e.args[2].args[1], e.args[2].args[pos]
           return esc(e);
       end
@alajs (macro with 1 method)

julia> @alajs (y, rest...) = (x=1, y=2, z=3)
(y = 2, x = 1, z = 3)

julia> y
2

julia> rest
(x = 1, z = 3)

If someone explains how to expand within the macro the symbol r in the namedtuple that defines it, it would also be valid for expressions like:

@alajs (y,rest...)=r