> That is a bit surprising indeed. Maybe worth an addition to > > http://docs.julialang.org/en/latest/manual/methods/#note-on-optional-and-keyword-arguments > > ? >
It's not only surprising, I'd consider it (absent a real reason why it should be this way) incorrect. Once you've decided which method you're going to use (in this case, f()), the system shouldn't suddenly "switch". Consider what might happen if the optional parameter depends on an external variable/process (simple case below): julia> a = 5 5 julia> function f(d=a) info("in f1"); d; end f (generic function with 2 methods) julia> function f(a::Float64) info("in f2"); round(Int,a); end f (generic function with 3 methods) julia> f() INFO: in f1 5 julia> a = 6.6 6.6 julia> f() INFO: in f2 7 This is undesirable for a number of reasons.