2017-11-07 13:47 GMT+01:00 Denis Kudriashov <[hidden email]>:
My position is that we have few messages (which are not business logic related) for sorting, so they could easily extend collection (and #yourself here is just noise). Now, you want to keep that mix of business logic + ordering, hence the syntax you're choosing. Thierry |
In reply to this post by Thierry Goubier
2017-11-07 13:50 GMT+01:00 Thierry Goubier <[hidden email]>:
Sorry Thierry that it is not obvious: given name is an example. Of course it is better to have explicit name.
|
In reply to this post by Nicolas Cellier
I have new question. Why we really need threeWayCompareTo:? DefaultSortFunction can implement it using standard comparison methods. 2017-11-05 0:37 GMT+01:00 Nicolas Cellier <[hidden email]>:
|
In reply to this post by Denis Kudriashov
2017-11-07 13:59 GMT+01:00 Denis Kudriashov <[hidden email]>:
Understood :) Thierry
|
In reply to this post by Denis Kudriashov
2017-11-07 14:20 GMT+01:00 Denis Kudriashov <[hidden email]>:
But what would the DefaultSortFunction use? 2 among the 3 selectors < = > ? It's just that we might scan String twice when <=> would do it once, but apart that is OK
|
2017-11-07 14:40 GMT+01:00 Nicolas Cellier <[hidden email]>:
Yes, you are right. And we already have VM based String compare: with strange logic returning 1, 2, 3. So we already can optimize current String>>threeWayCompareTo:.
|
2017-11-07 14:45 GMT+01:00 Denis Kudriashov <[hidden email]>:
Maybe good idea to open ticket and modify image level methods to return standard -1,0,1 values.
|
In reply to this post by Ben Coman
Which is weird because I think the magic is its decentralized nature.
|
In reply to this post by Denis Kudriashov
On 7 November 2017 at 14:48, Denis Kudriashov <[hidden email]> wrote: --
If we're modifying core sorting methods, we might as well use proper objects instead of magic numbers… Ordering Lesser Equal Greater (Unordered?) And while I'm on the topic of vocabulary, I'm not convinced by SortFunction… "to sort" means either to screen, to classify, or to arrange. There is a notion of going through all elements and swapping them around or putting in specific bins. Think QuickSort, MergeSort, etc The mathematical term for the thing that determines whether two elements a and b are such that a ≤ b is "Order relation". So IMHO Java's Comparator fits the purpose much better; OrderFunction or OrderRelation would be nice and just Order would have my preference: Order with: aPredicate (Order with: [:a :b | a < b]) value: 1 value 2. → the singleton instance of Lesser Order by: aMappingBlock people sorted: (Order by: #name) , (Order by: #age) Lesser >> #, innerOrder ^ self Equal >> #, innerOrder ^ innerOrder |
On 9 November 2017 at 14:00, Damien Pollet <[hidden email]> wrote:
oh well, I got the Order composition and the Ordering flattening mixed up, but you get the idea :) |
In reply to this post by Damien Pollet
Hi Damien.
I also thought about it. But it looks like overengineering to me. These magic numbers are too well known to be magic. Do you have real cases where this approach will improve the code?
|
Not really, but I'd be interested in understanding why it's overengineering for Ordering but not for Boolean… On 9 November 2017 at 14:16, Denis Kudriashov <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |