[swift-evolution] Marking sort and sorted with rethrows
Tim Vermeulen
tvermeulen at me.com
Wed Jun 8 06:31:10 CDT 2016
Not that I know of. It’s rather an attempt at making the standard library more consistent. The main reason being that the `isOrderedBefore` parameter in `max(isOrderedBefore:)` has the exact same type (`@noescape (Iterator.Element, Iterator.Element) -> Bool`) except that it is allowed to throw. I know that there’s no good reason to not let `max` rethrow, but for the sake of consistency, I figured it would make sense and it would be feasible to let `sort` and `sorted` also rethrow.
> > On Jun 7, 2016, at 12:07 PM, Tim Vermeulen via swift-evolution<swift-evolution at swift.org>wrote:
> >
> > > True, but the cost of being able to restore the original ordering, when
> > > that restoration may not be needed at all, is prohibitive.
> >
> > What about simply restoring the elements, in no particular order? This seems like an easy enough task, and I don’t think it requires the sorting algorithm to allocate any extra memory (in case no error is thrown, at least).
> What is the example that motivates this? Is there a widely used comparison function that throws?
>
> -Chris
>
>
>
More information about the swift-evolution
mailing list