Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keyword arguments are not part of the function signature #17596

Closed
randomizedthinking opened this issue Jul 24, 2016 · 2 comments
Closed

keyword arguments are not part of the function signature #17596

randomizedthinking opened this issue Jul 24, 2016 · 2 comments

Comments

@randomizedthinking
Copy link

Not sure whether this is by design or something can be improved upon.

myfunc(; x::Int64=1) = x + 1
myfunc(; y::Int64=1) = y + 1

Below are the results of calling these functions.

julia> myfunc(x=1);
ERROR: unrecognized keyword argument "x"
julia> myfunc(y=2);

The second definition of myfunc overrides the first one given that keyword arguments are not part of the function signature. It implies we can define generic functions with different keyword arguments.

The question is whether it is by design, or is there any way to achieve the similar effect?

@yuyichao
Copy link
Contributor

This is by design, documented (kwargs doesn't participate in dispatch) and raise a warning on 0.5.

@JeffBezanson
Copy link
Member

See #16580 for some work & discussion towards handling keyword args more like positional args.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants