I see in the manual http://docs.julialang.org/en/latest/manual/methods/#note-on-optional-and-keyword-arguments that:
"Keyword arguments behave quite differently from ordinary positional arguments. In particular, they do not participate in method dispatch. Methods are dispatched based only on positional arguments, with keyword arguments processed after the matching method is identified." I don't think you defined 2 different methods. You defined one method taking no positional arguments and a bunch of keyword arguments. Then you overwrote that method. On Saturday, January 30, 2016 at 11:37:51 AM UTC-5, Daniel Carrera wrote: > > This is very weird. It looks like multiple dispatch doesn't work at least > in some cases. Look: > > julia> semimajor_axis(;M=1,P=10) = (P^2 * M)^(1/3) > semimajor_axis (generic function with 1 method) > > julia> semimajor_axis(;α=25,mp=1,M=1,d=10) = α * d * M/mp / 954.9 > semimajor_axis (generic function with 1 method) > > julia> semimajor_axis(M=3,P=10) > ERROR: unrecognized keyword argument "P" > > > I do understand that it may be risky to have two functions with the same > name and different named parameters (I really wish Julia allowed me to make > some/all named parameters mandatory), but I was expecting that my code > would work. I clearly defined a version of the function that has a named > parameter called "P". > > Does anyone know why this happens and what I can do to fix it? Am I > basically required to either use different function names, or give up on > using named parameters for everything? > > Cheers, > Daniel. >