-
Notifications
You must be signed in to change notification settings - Fork 55
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
Add support for f ∘ g #317
Conversation
@bkamins can I get an review? I have code ready based on this which will do the more substantive change of transforming |
@@ -187,4 +189,38 @@ using DataFramesMeta | |||
end | |||
end | |||
end | |||
|
|||
@testset "composed compilation" begin | |||
@eval begin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here - I do not understand the benefit of @eval
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned above, @eval
is necessary because we need to evaluate in global scope to prevent caching the anonymous function in the method table.
|
||
for _ in 1:2 | ||
@eval begin | ||
@test @select(df, :y = (f ∘ g)(:a, :b)).y == [3] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think testing timing is enough? Maybe also generated code should be tested?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't check generated code anywhere else. I think this should be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind it's easy to add. Added. Will merge after tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from the comments left I think it looks good. The code assumes that ∘
is not redefined by the user, but I think it is a valid assumption (though maybe it should be noted somewhere).
No that's a good catch. Overall I'm not very good with macro hygiene in this package and should fix it. |
I am not sure who is good at macro hygene 😄 (e.g. I do not write macros often and in consequence it is really hard for me to do it properly when I do). |
Macro hygiene doesn't matter here, actually. Since the expression |
This PR does not transform
f(g(:x))
to(f ∘ g)(:x)
.Rather, it ensures that the expression
gets turned into
which is a good first step for transforming
f(g(x))
.I'm leaving this undocumented for now, since it's a behind-the-scenes transformation.