on Thu Apr 13 2017, Jonathan Hull <[email protected]> wrote:
> I still like the ordering of floats defined in this proposal best (and > think we should use it), but I imagine that there are other types > which are almost (but not quite) comparable as well. Would there be > any utility in having a ‘PartialComparable’ protocol that defined a > single method: > > func compare(_:)->ComparisonResult? > > That is, it is just like our compare, but it returns nil if two values > can’t be meaningfully compared. It would force you to deal with the > cases where the comparison didn’t make sense, and handle it in a > reasonable way in your code. (e.g. filtering those values out, or > sticking them at the end). > > You can think of it as failable compare... The first question when proposing a new protocol is always: what generic algorithm can take advantage of this API? -- -Dave _______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
