[swift-evolution] [Pitch] Introducing the "Unwrap or Die" operator to the standard library
retired.hunter.djura at gmail.com
Wed Jun 28 01:52:17 CDT 2017
Yep, "logic" failures are not supposed to be there if not for avoiding checks that could worsen performance in pieces of code that should run as fast as possible. I like Adrian's solution because it doesn't add a new operator to the standard library, something that could mean one more encouragement to force unwrap things.
About preconditions, Cocoa with Love's Matt Gallagher wrote an article some months ago on partial functions, why you should avoid them and how to do so: it's a very interesting read http://www.cocoawithlove.com/blog/2016/01/25/partial-functions-part-one-avoidance.html <http://www.cocoawithlove.com/blog/2016/01/25/partial-functions-part-one-avoidance.html>
> Il giorno 28 giu 2017, alle ore 07:02, Yuta Koshizawa via swift-evolution <swift-evolution at swift.org> ha scritto:
> Logic failures are intended to be handled by fixing the code. It means
> checks of logic failures can be removed if the code is tested enough.
> Actually checks of logic failures for various operations, `!`,
> `array[i]`, `&+` and so on, are designed and implemented to be removed
> when we use `-Ounchecked`. It is useful for heavy computation like
> image processing and machine learning in which overhead of those
> checks is not permissible.
> So I think checks for `!!` should be removed with `-Ounchecked` as well.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution