-
-
Notifications
You must be signed in to change notification settings - Fork 704
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
Issue 13595: Extend groupBy to handle non-equivalence relations. #2654
Conversation
|
Beware of "Boolean Blindness" (http://existentialtype.wordpress.com/2011/03/15/boolean-blindness/ ). |
|
I thought about that, but recently Andrei seems ill-disposed towards the use of |
|
On second thoughts, using an enum for it (like the rest of |
|
Why not a second name? eg |
|
Hmm. That's definitely a possibility, but I don't know if |
adbe5cf
to
5ba0fa0
Compare
|
Rebased. |
|
I like the changes, it is much less confusing for newcomers that way. No idea if |
|
Hmm. What about |
|
Yeah that makes sense - fits D principle "safe and powerful by default, extra performance if asked for explicitly". Again, won't judge naming choice :P |
|
groupByEquivRelation seems far too long to me, in the same realm as binaryReverseArgs, and so nobody will want to use it. |
|
I like to write, but I am not native English, so my choice of very short names is sometimes not the best. I think groupByEquivRelation is a bad name. I agree that "binaryReverseArgs" is a too much long name and I am discouraged to use such function just because of its name, it should be renamed "flipTwo" or something similar. I think that using an enum or Flag is better for this specific case because inventing a fitting name is not easy and it risks becoming a too much specialized function. As usual you need to balance different desires and constraints. |
|
Keeping |
|
(misclick) |
|
So everyone agrees that the previous version (two overloads of |
|
Well, unless some mathematician comes and proposes short and clear name for |
|
What about just |
|
ping |
|
With no new opinions I'd call for going back to version with flag (and using slower version that does not require equivalence as default) |
bd9228a
to
5ba0fa0
Compare
|
Alright, reverted back to the version with the flag. Should |
|
In my code I'll use this function only rarely. What I usually look for is a hashGroup (that returns an associative array). |
I have no preferences on this topic so whatever suits you. @bearophile I think it should be possible to define |
|
Recently there were some PR's that changed single-use enums into aliases of I think it's a good idea, even though |
Update DDocs. Add unittest for 13595.
To prevent Boolean Blindness.
5ba0fa0
to
a61fb6e
Compare
|
Rebased, use |
|
Renamed. |
|
LGTM |
|
Thanks! |
|
@Dicebot, the semantics is different so we'll probably need a different function (like hashGroup or something similar). |
|
Auto-merge toggled on |
|
Fine by me |
Issue 13595: Extend groupBy to handle non-equivalence relations.
|
@quickfur I've found a problem, but I am not sure if the cause is groupBy. I have put the code in Bugzilla, in issue 13595. |
|
I think we need to revert this until https://issues.dlang.org/show_bug.cgi?id=13936 reaches a conclusion. |
|
Then you'll have to take out #1453 as well, since that's the original implementation. This one is just a fixup. |
Update DDocs.
Add unittest for 13595.
Supporting non-equivalence relations (treated as a predicate between adjacent elements) allows for more interesting predicates, like maximum adjacent difference (added as ddoc example), word boundary testing, etc.. This comes at a performance cost, though, so the
isEquivRelationparameter was added to fallback to the original implementation when the user is sure their predicate is an equivalence relation.