-
Notifications
You must be signed in to change notification settings - Fork 66
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
Trouble understanding @turbo and passing kwargs #493
Comments
The struct KwargCall{F,T}
f::F
x::T
end
@inline (f::KwargCall)(args...) = f.f(args...; f.x...) Then julia> function turbofun2(x, y; a=2)
return x * y - a
end
turbofun2 (generic function with 1 method)
julia> f = KwargCall(turbofun2, (a=10,));
julia> f(1,3)
-7 You can have the macro replace kwarg functions with |
Should I just add """
KwargCall(fun, kwarg)
replace kwarg functions with KwargCall to allow passing to @turbo
"""
struct KwargCall{F,T}
f::F
x::T
end
@inline (f::KwargCall)(args...) = f.f(args...; f.x...) to Then export it... then add a description to the readme? |
I would only add it to the package if you can make the macro automate applying it. If you don't want to update the macro, you could add using an anonymous function to the docs. |
A note and solution have been added in #494 |
I've posted this question on Discourse but I'm now starting to wonder if it's specific to @turbo. I can see that the developer is overwhelmed.. hopefully my questions is helpful.
https://discourse.julialang.org/t/trouble-understanding-turbo-and-passing-kwargs/99023
Repeating hear so no one needs to follow the link.
After searching for awhile I'm stuck trying to understand why
This works fine
and so does this
but not this
I get a cryptic error:
I suspect the answer is obvious but I'll be damned if I can find an answer
The text was updated successfully, but these errors were encountered: