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

Support default argument values #25

Open
shashi opened this issue Feb 3, 2021 · 1 comment
Open

Support default argument values #25

shashi opened this issue Feb 3, 2021 · 1 comment

Comments

@shashi
Copy link
Contributor

shashi commented Feb 3, 2021

Is this supposed to work?

julia> f = @RuntimeGeneratedFunction(:(f(x,z=3) = y))
ERROR: argument malformed. Got $(Expr(:kw, :z, 3))
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:33

Can it be made to work? I'm trying to use this to get stuff like this https://github.com/mcabbott/Tullio.jl/pull/81/files#diff-5e84de38fb08a2615207f16bf896e93ccb8c58bbfa50e6420fc8d54d88daca84R1082 to work since I want to use the @tullio macro inside generated function body... is it technically infeasible?

@c42f
Copy link
Contributor

c42f commented Feb 6, 2021

I think this is probably feasible. f(x,z=3) is normally lowered to a pair of methods and dispatch figures out which one to call. For RGFs we only really have one method (albeit parametric) so it's probably necessary to add some dynamic code to the body of the RGF to simply fill in any default arguments if the args list is too short. I think this would be compiled efficiently, though you'd have to check.

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

2 participants