[swift-evolution] Throws? and throws!
Tino Heth
2th at gmx.de
Mon Jan 16 07:44:22 CST 2017
> My intended framing of this does not seem to be coming across in my arguments. I am not thinking of this as a way to avoid typing ‘try!’ or ‘try?’. This is not intended to replace any of the current uses of ‘throws’. Rather, it is intended to replace trapping and nil-returning functions where converting it to throw would be burdensome in the most common use cases, but still desirable in less common use cases. In my mind, it is only enabling the author to provide extra information and flexibility, compared to the current behavior.
I'm more or less neutral towards the proposal, but to express my perception, one part seems similar to the use of "!" in variable declarations (like IB does):
It just makes force unwrapping (or, here: assuming that no error happened) the default, but leaves all other options intact.
But Afaics, force unwrapped variables are considered a bad practice that should be avoided (nearly) wherever possible…
The "try?-replacement" could be more useful for me: In my codebase, I have several throwing functions paired with computed properties (returning an Optional of the same type) that directly map to them, and at the call site, I usually don't care about the error.
I'm not sure if it's useful enough to justify new syntactic sugar for it, though — especially as I think it's not very intuitive.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170116/c25fe4b0/attachment.html>
More information about the swift-evolution
mailing list