This solution is nifty indeed, and has the chief advantage of working.<br><div class="gmail_quote"><div dir="ltr">On Tue, Jun 27, 2017 at 16:55 Max Moiseev via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><blockquote type="cite"><div>On Jun 27, 2017, at 1:03 PM, Adrian Zubarev &lt;<a href="mailto:adrian.zubarev@devandartist.com" target="_blank">adrian.zubarev@devandartist.com</a>&gt; wrote:</div><br class="m_-8152363839179283491Apple-interchange-newline"><div><div class="m_-8152363839179283491bloop_markdown" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254)"><p style="margin:15px 0px">How about?</p><pre style="margin:15px 0px;font-family:Menlo,Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-size:10pt;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-color:rgb(248,248,248);color:inherit;border:1px solid rgb(204,204,204);overflow:auto;padding:4px 8px;word-break:normal;word-wrap:normal"><code style="font-family:Menlo,Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-size:10pt;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-color:rgb(248,248,248);color:inherit;border:0px;margin:0px;padding:0px;word-break:normal;word-wrap:normal">public func ?? &lt;T&gt;(optional: T?, noreturnOrError: @autoclosure () throws -&gt; Never) rethrows -&gt; T {
    switch optional {
    case .some(let value):
        return value
    case .none:
        try noreturnOrError()
    }
}
</code></pre><div style="margin:15px 0px"><br class="m_-8152363839179283491webkit-block-placeholder"></div></div></div></blockquote></div></div><div style="word-wrap:break-word"><div>Yeah, I saw your email right after I sent mine =)</div><div>This works, I tried it and also ran the test suite. There was only one error.</div><div><br></div><div><font face="SFMono-Regular"><span style="font-size:11px">  var s: String = ns ?? &quot;str&quot; as String as String // expected-error{{cannot convert value of type &#39;NSString?&#39; to expected argument type &#39;String?&#39;}}<br>                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>                                                                     cannot convert value of type &#39;String&#39; to expected argument type &#39;NSString&#39;</span></font><br><br><div><br></div><div>I now wonder what the effect on the source compatibility suite would be:</div><div><a href="https://github.com/apple/swift/pull/10639" target="_blank">https://github.com/apple/swift/pull/10639</a></div></div></div><div style="word-wrap:break-word"><div><div><br></div><div><br></div><div>Max</div></div></div><div style="word-wrap:break-word"><div><br><blockquote type="cite"><div><div class="m_-8152363839179283491bloop_original_html" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254)"><div id="m_-8152363839179283491bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;margin:0px"><br></div><br><div id="m_-8152363839179283491bloop_sign_1498593590478208000" class="m_-8152363839179283491bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">-- <br>Adrian Zubarev<br>Sent with Airmail</div></div><br><p class="m_-8152363839179283491airmail_on" style="margin:15px 0px">Am 27. Juni 2017 um 21:54:57, Max Moiseev via swift-evolution (<a href="mailto:swift-evolution@swift.org" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" target="_blank">swift-evolution@swift.org</a>) schrieb:</p><blockquote type="cite" class="m_-8152363839179283491clean_bq" style="margin:15px 0px"><span style="margin-top:0px;margin-bottom:0px"><div style="word-wrap:break-word"><div></div><div><br><div><blockquote type="cite" style="margin:15px 0px"><div style="margin-top:0px">On Jun 27, 2017, at 10:38 AM, Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_-8152363839179283491Apple-interchange-newline"><div style="margin-bottom:0px">As you write, this operator becomes sugar for “?? fatalError()” once Never becomes a true bottom type.<br><br>In the meantime, can’t the same thing be accomplished by overloading fatalError so it’s a generic function that returns a discardable result of type T, which in turn calls the Never-returning overload?<br></div></blockquote><div><br></div><div>I like this idea more than adding an extra operator, but overloading fatalError won’t work now because of <a href="https://github.com/apple/swift/blob/master/stdlib/public/core/Optional.swift#L668" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" target="_blank">https://github.com/apple/swift/blob/master/stdlib/public/core/Optional.swift#L668</a></div><div><br></div><div><br></div><div><br></div><br><blockquote type="cite" style="margin:15px 0px"><div style="margin-top:0px;margin-bottom:0px"><div class="gmail_quote"><div dir="ltr">On Tue, Jun 27, 2017 at 12:25 Erica Sadun via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br></div><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 style="margin-top:0px;word-wrap:break-word"><div>Using an operator to provide feedback on the context of a failed unwrap has become a commonly implemented approach in the Swift developer Community. What are your thoughts about adopting this widely-used operator into the standard library?</div><div><br></div><div><font face="Menlo">guard !lastItem.isEmpty else { return }</font></div><div><font face="Menlo">let lastItem = array.last !! &quot;Array must be non-empty&quot;</font></div><div><br></div><div>Details here:  <a href="https://gist.github.com/erica/423e4b1c63b95c4c90338cdff4939a9b" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" target="_blank">https://gist.github.com/erica/423e4b1c63b95c4c90338cdff4939a9b</a></div><div><br></div><div>Thank you for your thoughtful feedback, -- E</div><div><br></div></div>_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br style="margin-bottom:0px"></blockquote></div>_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div></blockquote></div><br>_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div></div></span></blockquote></div><div class="m_-8152363839179283491bloop_markdown" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254)"></div></div></blockquote></div></div>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>