This is what keyword arguments are for.
http://docs.julialang.org/en/stable/manual/functions/#keyword-arguments

--Tim

On Thursday, January 07, 2016 11:02:03 AM Josh Day wrote:
> 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?

Reply via email to