<div dir="ltr"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><span style="font-size:14px">"In -Ounchecked builds, the optimizer may assume that this function is never called. Failure to satisfy that assumption is a serious programming error.”</span></div></blockquote><div><br></div><div>Yes, and so the following `!!` can perform identically to `!` in -Ounchecked builds when it is inlined.</div><div><span style="color:rgb(0,0,0);white-space:pre-wrap"><br></span></div><div><font color="#000000"><span style="white-space:pre-wrap">public static func !!(optional: Optional, errorMessage:
@autoclosure () -> String) -> Wrapped {
precondition(optional != nil, errorMessage())
return optional!
}</span></font></div><div><font color="#000000"><span style="white-space:pre-wrap"><br></span></font></div><div class="gmail_extra"><div><div class="gmail_signature">--<br>Yuta</div></div><div class="gmail_signature"><br></div>
<br><div class="gmail_quote">2017-06-29 6:42 GMT+09:00 Jaden Geller <span dir="ltr"><<a href="mailto:jaden.geller@gmail.com" target="_blank">jaden.geller@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-"><br>
> On Jun 28, 2017, at 7:47 AM, Erica Sadun via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br>
><br>
><br>
>> On Jun 28, 2017, at 3:52 AM, Yuta Koshizawa via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br>
>><br>
>> Hi, I think it is an orthogonal issue if we need a new operator. It is<br>
>> also possible to introduce an infix `!` for it.<br>
>><br>
>> I am sure that we do not need to avoid `precondition` as long as we<br>
>> use it appropriately. It is useful to realize consistent behavior with<br>
>> `Array`'s `subscript`, forced unwrapping `!`, `&+` and so on. In this<br>
>> context, `precondition` does not mean a general word "precondition"<br>
>> but the `precondition` function in the Swift standard library, which<br>
>> is removed when -Ounchecked.<br>
><br>
><br>
> How would the line run then? Would it simply act as a forced unwrapped under -Ounchecked?<br>
<br>
</span>From the docs:<br>
<br>
"In -Ounchecked builds, the optimizer may assume that this function is never called. Failure to satisfy that assumption is a serious programming error.”<br>
<br>
Aka, v. bad things happen if the precondition does not hold.<br>
<div class="gmail-HOEnZb"><div class="gmail-h5"><br>
><br>
> -- E<br>
><br>
> ______________________________<wbr>_________________<br>
> swift-evolution mailing list<br>
> <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br>
</div></div></blockquote></div><br></div></div>