[swift-evolution] Marking sort and sorted with rethrows

Chris Lattner clattner at apple.com
Wed Jun 8 12:21:57 CDT 2016


> On Jun 8, 2016, at 7:52 AM, Brent Royal-Gordon <brent at architechies.com> wrote:
> 
>> Is there a widely used comparison function that throws?
> 
> Any comparison function that examines external data related to the instance:
> 
> * Sorting filenames by the data in the corresponding files
> * Instances backed by a database where actually loading the data could fail
> * Etc.

Ok, instead of using rethrows, would it be a better overall design be to define two overloads, one that takes a throwing closure and one that doesn’t?  This allows the throw-supporting implementation to be slower without punishing the normal case..

-Chris


More information about the swift-evolution mailing list