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