[swift-evolution] Move placement of 'throws' statement
David Waite
david at alkaline-solutions.com
Tue Dec 27 10:59:50 CST 2016
Imho the concept of checked exceptions was ok, but the important information is the category of error - in how to respond and how to report to the user. Use of a type system encourages an ontology of errors by subsystem and not by appropriate programmatic response. You could have appropriate user interaction or recovery in response to "specified file was not found", but not to "some IO error has occurred".
Eventually this impedance mismatch grew to having modules (packages) in Java "wrap" all errors in a module-specific error. Now it wasn't even "some IO error occurred" but "some error occurred in the XML module"
This is the danger of checked exceptions - that abstracting away the error makes it harder to reason about dealing with the error, so you just delegate further up the call stack, abstracting further as you go
-DW
Sent with my Thumbs
> On Dec 27, 2016, at 6:21 AM, Charlie Monroe via swift-evolution <swift-evolution at swift.org> wrote:
>
> You need to list all exception types that can be thrown. And when you call another throwing method without handling the exception, it needs to be listed as well. Which means that you can end up with a method that has a list of a dozen of exception names that can be thrown.
>
>> On Dec 27, 2016, at 11:56 AM, Derrick Ho via swift-evolution <swift-evolution at swift.org> wrote:
>>
>> Daniel Leping, I am unfamiliar with java. Do you have any resources that describe the nightmare in detail?
>> On Tue, Dec 27, 2016 at 2:50 AM Tino Heth <2th at gmx.de> wrote:
>>>> -1 for specifying errors for throws. Please don't. Proven by practice in java it's a nightmare.
>>>
>>> In Java, this topic is really interesting:
>>> It sounds like a great idea, but in real-life situations, afaics everyone hates checked exceptions.
>>>
>>> But Swift isn't Java, and our error handling is different from most established languages, so imho we shouldn't base that decision on experiences from other models only:
>>> I don't see downsides, because you already need "try" for everything that can throw, and afaics, it would be easy to ignore the information that only a set of exceptions can happen in a given context.
>>>
>>> So, imho before there is a decision wether "throws" should be moved, the possibility to annotate it with a fixed set of error types should be either abandoned or incorporated.
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>
> _______________________________________________
> 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/20161227/e8b2badf/attachment.html>
More information about the swift-evolution
mailing list