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 for static_hasmethod? #27

Open
cscherrer opened this issue May 24, 2021 · 4 comments · May be fixed by #28
Open

keyword arguments for static_hasmethod? #27

cscherrer opened this issue May 24, 2021 · 4 comments · May be fixed by #28

Comments

@cscherrer
Copy link

I think Tricks ought to be able to help us with KeywordCalls, especially cscherrer/KeywordCalls.jl#16.

But static_hasmethod seems to be missing keyword argument support:

julia> methods(static_hasmethod)
# 1 method for generic function "static_hasmethod":
[1] static_hasmethod(f, t::Type{T}) where T<:Tuple in Tricks at /home/chad/.julia/packages/Tricks/TyBuj/src/Tricks.jl:17

julia> methods(hasmethod)
# 2 methods for generic function "hasmethod":
[1] hasmethod(f, t; world) in Base at reflection.jl:1347
[2] hasmethod(f, t, kwnames::Tuple{Vararg{Symbol, N} where N}; world) in Base at reflection.jl:1353

For example, this works:

hasmethod(g, Tuple{}, (:a, :b, :c, :d))

You probably couldn't call it this way to resolve it statically, but maybe this could be done by representing the symbols at the type level, as in named tuple? Or maybe there's a fundamental problem with trying to reason about keyword arguments statically?

@oxinabox
Copy link
Owner

Yeah, I am sure we can make this work.

@cscherrer
Copy link
Author

We were able to update KeywordCalls without this, using hasmethod in the body of the macro (outside the quote). Stating the obvious, there's still lots of value in adding this functionality.

Also, cool package. Thanks for your work on it :)

@oxinabox
Copy link
Owner

using hasmethod in the body of the macro (outside the quote).

Yeah that is not a good as this, since it will not react to things being added interactively.
I am not sure it will react correctly to methods defines in packages loaded after this one or not either.

@cscherrer
Copy link
Author

Good point, thanks. In this case it's just there to avoid warnings for defining duplicate methods, but we should check that. I'll add an issue.

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

Successfully merging a pull request may close this issue.

2 participants