julia> foo(a; b, d="d", e="e") = (@show a b d e)
foo (generic function with 1 method)
julia> foo(a; m, d="d", e="e") = (@show a m d e)
foo (generic function with 1 method)
julia> foo(a; b, c, d="d", e="e") = (@show a b c d e)
foo (generic function with 1 method)
Is there a particular reason why this doesn’t work? I assume if the keyword argument does not have a default value, there shouldn’t be any ambiguity to choose which method to call?
Sorry, I think maybe I haven’t conveyed my question clearly enough. My question is more like “why don’t different keyword parameters specify multiple dispatches”.
If they are optional parameters I can understand because we would encounter cases where the number and the types of the required (position) arguments are the same, which creates ambiguity for which method to call.
However, if those keyword arguments are not optional parameters, that means apart form passing additional variable names to pair with the arguments’ value, they “should” be no different from (position) arguments.
As for (position) arguments, we don’t need to define a specific type of each argument to form multiple dispatches, just the number of arguments is enough:
julia> g(a) = nothing
g (generic function with 1 method)
julia> g(a, b) = nothing
g (generic function with 2 methods)
I would like to know the language design philosophy behind this decision.