Unlike Python, Julia makes a distinction between positional and keyword arguments. You can’t pass the same argument either through position or through name. In particular, positional arguments participate in dispatch, selecting the specific method invoked, and keyword arguments do not.
However, if you have only one method, you can emulate this with something like
f(x, _y=1; y=_y) = (x,y)
or, if you want to disallow calls like f(1,2,y=2)
function f(x, _y=nothing; y=nothing)
if isnothing(_y) && isnothing(y)
y = 1
elseif !isnothing(_y) && !isnothing(y)
error("two values assigned to y")
else
y = something(y,_y)
end
(x,y)
end
You can also dispatch on the types of (x,y) using f(x, _y=1; y=_y) = _f(x,y) and doing the dispatch in _f.