-
Notifications
You must be signed in to change notification settings - Fork 5
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
Macros that take only symbols for arguments #2
Comments
Option 5: Use a |
Maybe only support |
The |
Actually, I just realized that the present solution still runs into trouble if somebody does something like
It's still possible to handle this case with the |
Hmm, I'm now much less convinced that the tbl = Table(a = [1,2,3])
@select(ttbl, a) won't throw an error complaining about there being no such object I'm starting to despair at the possibility of providing piped versions of commands whose arguments apart from the data source can be symbols. I'm definitely not a fan of providing some pipable commands and some not pipable ones. Perhaps @bramtayl is right in that only non-pipable one-off commands should be offered, and people can rely on Lazy.jl to chain them. Of course, if people don't mind calling |
I would suggest the opposite: require that data be explicitly fed into a computational graph. See the strategy in TensorFlow for an example: https://www.tensorflow.org/versions/r0.10/how_tos/reading_data/index.html#feeding |
So, simply have no "one-off" macros at all? |
Possibly. |
I'm not opposed to that. It would bring us closer to a "one way to do things" set up, which I like. Though it might be nice to have a variant of |
Now that one can dispatch on macro arguments, it is easy to write two distinct
@filter
"methods" -- one that expects a data source as a first argument,and one that expects only filtering expressions
However, with verbs like
select
, the situation is more complicated, because the arguments to the macro are allSymbol
s. That is, macro dispatch cannot tell the difference between being passed a data source and columns and just being passed columns:@select(iris, SepalLength, Species)
and@select(SepalLength, Species)
see the same argument signature. The upshot is that we cannot distinguish between the case in which a data source, sayiris
is piped to@select(SepalLength, Species)
and the case in which it is provided as an argument. So it's not clear to me how to provide support for both cases. Some options:@select(args...)
, e.g. checkisdefined(args[1]) && isa(eval(args[1]), DataFrame)
. This is fairly inflexible - in particular, it will be incorrect if the data source is not defined in global scope.@select
to be somehow wrapped in order to turn them intoExpr
objects as registered at macroexpand-time: e.g.@select(Data.iris, SepalLength, Species)
._select
) dispatch on the type of the first argument. If the type of the first argument is not a data source, return a curried function. EDIT: The main difficulty here is that the first argument may or may not be a valid name.@select(iris, SepalLength, Species)
oriris |> @select(SepalLength, Species)
, but not both.1 seems like a non-starter. 3 may be tricky, because (as explained in #1), for
@filter
we create the DAG at macrocompile time. While@select
doesn't require this, it might make DAG creation from chaining within an@query
call difficult. I will defer choosing between 2 and 4 until I am convinced that 3 cannot be made to work.The text was updated successfully, but these errors were encountered: