[swift-evolution] Dropping Comparable requirement for indices

Xiaodi Wu xiaodi.wu at gmail.com
Fri Jul 8 15:58:53 CDT 2016


This sounds like a scenario where you'd be using or extending an existing
stdlib generic type such as Set, no?
On Fri, Jul 8, 2016 at 15:53 Tino Heth via swift-evolution <
swift-evolution at swift.org> wrote:

> Right now I'm working on a lib for charts/plots, and I choose to create a
> custom interval-type that has no comparable requirement.
> Of course, as soon as I leave the completely abstract and generic world, I
> need to bring things into an order — but if this order has to be defined by
> a global function "<", there is a loss in flexibility.
> My plan is to use "<" as a default wherever possible to define my ranges,
> with the option to change it to a custom alternative; maybe similar
> reasoning can be applied to the index-problem.
>
> Tino
>
> Real world example:
> Let's assume I want to create a bar-chart to compare the population of
> several countries.
> There is no natural order for countries (I hope we can agree on that ;-),
> so no matter how I'd model them, it would feel wrong to define "<":
> Sort by name might be the most obvious choice, but it could also be the
> size, the timezone, average income, the peak hight of its highest
> mountain...
> Additionally, I might want to use different orders for different charts,
> which is only possible when I can change the function which dictates the
> order.
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160708/006f9437/attachment.html>


More information about the swift-evolution mailing list