[swift-evolution] typed throws

Matthew Johnson matthew at anandabits.com
Fri Aug 18 12:21:51 CDT 2017


> On Aug 18, 2017, at 12:05 PM, Joe Groff <jgroff at apple.com> wrote:
> 
> 
>> On Aug 17, 2017, at 9:58 PM, Chris Lattner via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>>> On Aug 17, 2017, at 7:39 PM, Matthew Johnson <matthew at anandabits.com <mailto:matthew at anandabits.com>> wrote:
>>> One related topic that isn’t discussed is type errors.  Many third party libraries use a Result type with typed errors.  Moving to an async / await model without also introducing typed errors into Swift would require giving up something that is highly valued by many Swift developers.  Maybe Swift 5 is the right time to tackle typed errors as well.  I would be happy to help with design and drafting a proposal but would need collaborators on the implementation side.
>> 
>> Typed throws is something we need to settle one way or the other, and I agree it would be nice to do that in the Swift 5 cycle.
> 
> My view of this is the opposite of Matthew's—the canonical examples of things for which untyped errors are the "right thing" due to unbounded failure modes, such as file IO, IPC, network communication, etc. are almost all things you also want to be 'async', so I don't think async makes typed 'throws' any more urgent to consider. As we've discussed in person, I feel like there's a strong argument to be made that 'async' should always imply untyped 'throws’.

That’s interesting. Have you looked at how people are using `Result<T, E: Error>` in current third party libraries that do async stuff?

Even when failure modes are unbounded it can still be very useful to categorize the kinds of errors that might happen and encourage thoughtfulness about recovery in a way that an untyped `Error` does not.  Maybe types are not the best way to solve that problem but I haven’t seen any alternative that looks promising.

> 
> -Joe

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170818/7854ca52/attachment.html>


More information about the swift-evolution mailing list