<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jun 28, 2017, at 6:26 PM, Xiaodi Wu <<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">On Wed, Jun 28, 2017 at 5:05 PM, ilya via swift-evolution <span dir="ltr" class=""><<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>></span> wrote:<br class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr" class=""><div class="">One could, for example, extend the existing<b class=""> documentation markup sign</b> <b class="">///</b> to pick up text as force unwrap messages:</div><div class=""><br class=""></div><div class=""><div class=""><span style="font-family:Menlo;font-size:11px" class=""> `let last = array.last! /// Array guaranteed non-empty`</span></div></div></div></blockquote><div class=""><br class=""></div><div class="">I did not call this out initially, but I feel like this is an important point to address:</div><div class=""><br class=""></div><div class="">In the initial example, repeated here in largely identical form, the desired comment is "array must be non-empty." In what way does that provide more information than a bare `!`?</div></div></div></div></div></blockquote><div><br class=""></div>That is why I changed it back to my "<i class="">guarantee</i>" version when replying:</div><div><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div><font face="Menlo" style="font-size: 11px;" class="">guard !array.isEmpty else { ... }</font></div><div><font face="Menlo" style="font-size: 11px;" class="">/* ... */</font></div><div><font face="Menlo" style="font-size: 11px;" class="">let finalElement = array.last !! "Array guaranteed non-empty"</font></div></blockquote><div><br class=""></div><div>The expected unwrap behavior is clear and audited, even when other code appears between the guard statement and the explained forced unwrap. </div><div><br class=""></div><div>As you point out, it's senseless to annotate a logical assertion known to be true ("must be non-empty") <i class="">unless that annotation enhances the expression of why and how this otherwise dangerous operation is taking place</i>. That explanation forms the mission statement of the `!!` operator.</div><div><br class=""></div><div>By explaining, the `!!` operator differs from the direct use of `!`. It explains a fact known to hold true that allows the lhs to safely unwrap. It provides this in a way that is succinct and readable. It naturally moves with the line of code it is part of. The adoption of `!!` has already broadly been integrated into any number idiomatic libraries. Coders have done so to differentiate an <i class="">audited known fact</i> from the stray `!`, which may or may not be followed by a comment.</div><div><br class=""></div><div>One last point: it is not the mission of document comments to provide any role beyond annotation. They are not there to guarantee preconditions, assertions, or any other behavioral contracts. They merely document.</div><div><br class=""></div><div>-- Erica</div><div><br class=""></div><div><br class=""></div><div><br class=""></div></body></html>