-
Notifications
You must be signed in to change notification settings - Fork 50
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
Make $x syntactic sugar for _.x #294
Comments
I would really like to see some syntactic sugar for I think I particularly like In this case, I think it's better to be obvious that the syntax doesn't conform to other paradigms of the language than it is to try to find an almost analogous behavior to map it to. A bit of brainstorming on the topic: Running with the Symbol syntax, perhaps Interpolating Symbolsy = :x
data |> @mutate(x = 2 * $y) # analogous to `rlang::!!` equal to data |> @mutate(x = 2 * :x) Interpolating Expressionsy = :(2 * :x)
data |> @mutate(x = $y) equal to data |> @mutate(x = 2 * :x) That said, I can't think of a way of implementing something like this as a macro step off the top of my head - maybe with a custom constructor for these data-specific expressions. |
Perhaps I'm missing something, but I think julia> macro test_dollar(e)
println(e)
e
end
julia> y = :x
julia> test_dollar($y)
# ERROR: syntax: "$" expression outside quote
# Stacktrace:
# [1] top-level scope at REPL[3]:1 |
Coming from R and the Tidyverse, I saw the way that DataFrames.jl uses
or reshaping:
So I was slightly confused by using It was one of the reasons I started learning DataFramesMeta.jl instead of Query.jl. Using |
|
I'm not sure this is really a good idea, but I'd like to get some feedback :) The idea would be that
$x
is just syntactic sugar for_.x
in the standalone query commands. So instead of writing:one could write
The benefit would be that one saves on character.
The text was updated successfully, but these errors were encountered: