On Sat, Jan 30, 2016 at 11:37 AM, Daniel Carrera <[email protected]> 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?
This is documented[1]. Not sure if there's plan to change that. [1] http://julia.readthedocs.org/en/latest/manual/methods/?highlight=keyword#note-on-optional-and-keyword-arguments > > Cheers, > Daniel.
