<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">+1. The force unwrap operator is basically a runtime assert that enforces the invariant that "this value should not be nil at this point of use, and if it is nil the programmer made a mistake". It is a perfectly legitimate tool for writing code that can't otherwise be expressed (cleanly or at all) using the other type system constructs.<div class=""><br class=""></div><div class="">Likewise for all the other postfix-! keywords ('as!', 'try!', etc).<br class=""><div class=""><br class=""></div><div class="">Austin<div class=""><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 2, 2016, at 11:53 PM, Rod Brown via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I’m on the side of the ‘!’ at the moment.</div><div class=""><br class=""></div><div class="">I see a lot of heat here going into hatred of the force unwrap operator, as if it should be avoided like the plague. I simply don’t see the need for such absolutism. It’s there for a reason.</div><div class=""><br class=""></div><div class="">There are definitely use cases where use of the force unwrap operator is unsafe. Specifically, a lot of direct property access shouldn’t be done with it because of the fact that even if you check, another thread may come in, switch the variable to “nil” and all of a sudden you have a crash despite your best efforts.</div><div class=""><br class=""></div><div class="">That said, if you properly reason about your code, the ! operator is a useful and reasonable access tool to unwrap the optional you know about.</div><div class=""><br class=""></div><div class="">I certainly don't agree that we need a language construct purely so we can write verbose things as a big scary warning.</div><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 3 May 2016, at 4:41 PM, Dominik Pich via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">;) yes. I know I can write let x = y! but IMHO THAT is too brief again.&nbsp;<div class="">I like the fact that <b class="">guard </b>makes you look what you do… it is a little bit like assert(x != nil)</div><div class=""><br class=""></div><div class="">guard! let x = y</div><div class=""><br class=""></div><div class="">it reads awesome and everybody can more easily see it is a potentially fatal &amp; important call</div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On May 3, 2016, at 1:38 AM, Jordan Rose &lt;<a href="mailto:jordan_rose@apple.com" class="">jordan_rose@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">We have that; it’s just ‘!’. :-)</div><div class=""><br class=""></div><div class="">Jordan</div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On May 2, 2016, at 12:09, Dominik Pich via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hello,<div class="">often the guard statement is used to only unwrap optionals. multiple guards will cause a lot of ‘overhead’.</div><div class="">also often if it doesn’t work. there is no easy way we can gracefully recover ;)</div><div class=""><br class=""></div><div class="">so how about we do the same as with try/catch where you can use try! and have a guard!</div><div class=""><br class=""></div><div class="">the <b class="">guard!</b> could just throw an exception …</div><div class=""><br class=""></div><div class="">regards</div><div class="">Dominik</div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></div></div></div></body></html>