Suppose I have a function that takes several arguments of different types
and each has a default value. What is the best way to specify all possible
methods where a user can specify an argument without entering the defaults
that come before it? I don't want to force a user to remember the exact
order of arguments. The example below may explain this better.
type A
a::Int
end
type B
b::Int
end
type C
c::Int
end
f(a::A = A(1), b::B = B(1), c::C = C(1)) = ...
I would like the user to be able to call f(C(3), B(2))instead of f(A(1),
B(2), C(3)). I could just implement the factorial(3)methods myself, but if
I want to do this for 5 types, it means I'm writing 120 methods.
Is this just a terrible idea and I should use keyword arguments?