I thought this may have be a documentation issue, but now I think I have misunderstood.
I’m following the optional and keyword arguments in the docs.
I was surprised by the following:
julia> f(a=1,b=2)=1+2b f (generic function with 3 methods) julia> f(b=1,a=2) ERROR: function f does not accept keyword arguments
It seems that I mistook the example to be referring to optional and keyword arguments, when it is only an example of optional arguments - that is fine.
However, the error message implanted in my mind that this is definitely (unambiguously) not a function that accepts keywords.
After some digging I realized I had thought I was looking at something like this definition (update: please see the comment below):
julia> f(; a=1,b=2)=2a+4b f (generic function with 3 methods) # **See the update below** julia> f(b=1,a=2) 8
Now, in the following, I expected to get a ambiguity error instead of
julia> f() 10
On reflection I suppose I was “expecting” one of two things:
- the definition
f(a=1,b=2)=a+2bto throw an error about a missing
;, or for
64 defintions of
f: 3 using positional arguments, and
31 using keyword arguments and
f()to throw an ambiguity error.
Obviously I’ve got something horribly wrong. Appreciate any help.