True, but this is a special case where arguments have unique types.  The 
reason I asked is for a type in OnlineStats.jl 
<https://github.com/joshday/OnlineStats.jl>, where more often than not, the 
user will probably change defaults.

StatLearn(x, y, L1Regression(), AdaGrad(), L2Penalty())

looks considerably cleaner than

StatLearn(x, y, model = L1Regression(), algorithm = AdaGrad, penalty = 
L2Penalty())

On Thursday, January 7, 2016 at 6:15:04 PM UTC-5, Tim Holy wrote:
>
> 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