-
Notifications
You must be signed in to change notification settings - Fork 360
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
change order of by
arguments to support do
syntax
#580
Comments
One other advantage: this would mean that it would be possible to use a varargs list of grouping variables:
|
Sounds like a good idea. Could probably be a more general rule: functions should always be the first argument, because of this syntax feature. Regarding the macro, the only difference with the |
@nalimilan Yes, that's all it does:
Keeping the capitalization consistent also seems like a good idea. |
I've pondered this too as part of thinking about use of macros and LINQ-like syntax: To me, it's a close call. Having the DataFrame object first seems more consistent and follows what other LINQ libraries do. I'm starting to think we should define methods with both argument orderings. Then, we get Either way, whatever we do for |
Defining both method is actually pretty common in base. +1 for that. Kevin On Sunday, April 20, 2014, Tom Short notifications@github.com wrote:
|
Yeah, if defining both doesn't create any issues, it's a possible solution. But then for consistency the version with the function as first argument should be reserved to the Or would it make sense for Julia to automatically detect what's the position of the argument the anonymous function corresponds to? It's pretty obvious: the first argument accepting a function should be chosen. Doesn't sound like a very complex rule for users, and it would avoid creating many duplicate functions with swapped arguments, which is going to create a mess if it happens to often. |
That would mean that the meaning of an expression depends on what methods are defined for a function, which is no good. It also wouldn't interact very well with |
Ah, right. To me |
I've considered making do-block syntax sugar for passing a keyword argument. However, since we don't dispatch on keyword arguments, that causes some conflicts – namely in the cases where |
In that case you'd need to always pass |
No, the idea would be that foo(a, b) do x
# stuff
end would be shorthand for this: foo(a, b, fun = x -> begin
# stuff
end) or something like that. |
Yeah, that's what I meant. |
Implemented in #643. |
If the function was the first argument to
by
, it would be possible to usedo
syntax for anonymous functions:Also, what about a convenience macro for creating dataframes from vectors? For example
The text was updated successfully, but these errors were encountered: