Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Simplify macro rewriters and avoid some prospective bugs #238
You may want to check this clean implementation of @select:
macro select(args...) foldl(args, init=NamedTuple()) do prev, arg @match arg begin :(everywhere()) => :_ ::Int && if arg > 0 end => :( merge($prev, QueryOperators.NamedTupleUtilities.select(_, Val(keys(_)[$arg]))) ) ::Int && if arg < 0 end => let sel = ifelse(prev == NamedTuple(), :_, prev) :( QueryOperators.NamedTupleUtilities.remove($sel, Val(keys($sel)[-$arg])) ) end ::QuoteNode => :( merge($prev, QueryOperators.NamedTupleUtilities.select(_, Val($(arg)))) ) ... end
Also, there're some prospective bugs that've been avoided, e.g., quoted
df |> @select(startwith("\"a\""))
I'll look through the rest of the PR when I have bit more time, but just a quick response on this: I think we could probably drop julia 0.7 support at this point. I think we should keep 1.0 support, given that that is the long term supported version of julia.