-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
rename: sort_by => sortby ? #1850
Comments
Just to add: most of the sort-specific functions have I'm not at all tied to using underscores, but I do think they should be made consistent. |
I'm also not really for or against underscores, but am very sold on consistency. |
Agree. Consistency is the most important to have. |
I prefer no-underscores, since if you try to use them everywhere consistently there are simply too many. We don't want |
I'm coming around to the no-underscores rule. |
Irrespective of the underscores, we should certainly not have @kmsquire How do |
Sorry, to be more clear, there is no
(*) there is no Without underscores, these we would have
Seeing this mess, I'm wondering if we could get rid of all of the specialized sorts, and just dispatch by singleton classes--i.e., something like type QuickSort end
type InsertionSort end
type MergeSort end
type TimSort end
quicksort = QuickSort()
insertionsort = InsertionSort()
mergesort = MergeSort()
timsort = TimSort()
function sort(v::Vector)
...
end
function sort(s::Quicksort, v::Vector)
...
end
function sort(s::Timsort, v::Vector)
...
end
... It would really clean up the mess of functions above, and getting rid of underscores wouldn't be a big deal. Kevin |
Types as tags! |
Writing it as
allows to call directly using the type instead, |
Also, agree that this seems like a good way to clean up the mess. |
I also think the |
Yes, that does look a bit cleaner--thanks @toivoh. I'll work up a patch. |
Create empty types only for dispatch, and remember passing through functions, looks awkward to me. |
I am not fully convinced of the |
I also have to say that some of the non-underscore names look very weird. |
The compiler will specialize methods on the |
Maybe can be more consistent a unique Type for flags on functions ( something like
? |
I think using a Flag type is probably not more efficient than using symbols. |
Maybe can be good a rule for naming Types with only are using has function options, like a Opt... or Flag... prefix ?
The name of the Function in Uppercase can be a good option if you want to use autocompletion of REPL ;) Like
But it's true that function name can looks redundant and can be too large
I don't know... a more simple and easy to tipping idea can be better |
I'm still an advocate for real sum types to replace the empty type enum pattern, but still provide us with its dispatch and error-finding advantages. |
I am actually ok with the various sort functions having different names (although you may wonder why I am not ok with the same in the case of norm) and people having to load the module for that. Only the defaults can be exported. |
@pao: can you give an example of what you mean by "real sum types" here? |
It's primarily a syntactic thing that could probably be fixed with a macro and Jeff no longer objecting to the pattern, but ideally if there's any overhead in creating an empty Haskell: data SortAlgorithm = QuickSort | InsertionSort | MergeSort -- etc. Scala: sealed abstract class SortAlgorithm
case object QuickSort extends SortAlgorithm
case object InsertionSort extends SortAlgorithm
case object MergeSort extends SortAlgorithm
// etc. (ugly syntax but "case" makes these enum singletons) |
I was actually thinking of @pao's Scala example as precedence for this pattern, although I was wondering how it would go over. @ViralBShah, even if we end up keeping all of the different names, do you think we should keep or get rid of the underscores? If we get rid of all of them, the names are a bit unwieldy. (c.f. #1539.) I have a patch almost finished, and should be able to submit it today for further discussion. |
Superseded by new sort API. |
See JuliaData/DataFrames.jl#139.
The text was updated successfully, but these errors were encountered: