[swift-evolution] [Review] Tuple comparison operators (was: Add a Lazy flatMap for Sequences of Optionals)

Guillaume Lessard glessard at tffenterprises.com
Tue Dec 22 22:13:24 CST 2015


> On 22 déc. 2015, at 19:40, Dave Abrahams <dabrahams at apple.com> wrote:
> 
> It’s very convenient for “<“ to correspond to the standard strict-weak ordering for a type where possible.  

Convenient maybe. Is it advisable for a standard library feature? Doubtful.

This is about the definition of <. It means “less than”.
This is why operator overloading has a bad reputation.

I don’t dispute the *usefulness* of the proposed feature; I dispute its proposed *name*.
Is ordering tuples needed so often that unclear nomenclature is advisable? No!

Back to fundamentals: (slightly paraphrased from api-design-guidelines)
- Clarity at the point of use is most important.
- Clarity is more important than brevity.
- Promote clear usage.

< does *not* mean “is ordered before”.
< does *not* have a clear meaning with composite data.

isOrderedBefore is a clear name.

I know that Comparable is documented with respect to sorting; it is unfortunate. Sortable would be a better name, given the way it is documented. Note that (apart from String) the concrete Comparables in the stdlib are numbers, stand-ins for numbers (index) or entities referenced by numbers (code points). String is the salient exception.

The proposed change would redefine < and would be against convention.
Highly unclear.

Cheers,
Guillaume Lessard



More information about the swift-evolution mailing list