<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 28, 2017, at 10:44 AM, Adrian Zubarev 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=""><div class="">Well the main debate is that, we all want early access to a feature that will be part of Swift as soon as `Never` becomes the bottom type. When this happens the `??` will automatically support the pitched behavior. Until then if we all agree that we should add it now in a way that will not break anything we can simply add an overload to `??` as I previously showed.<div class=""><br class=""></div></div></div></blockquote><div><br class=""></div><div>I believe we should add it now, but I like the recent observation that making <font face="Menlo" class=""><span style="font-size: 11px;" class="">??</span></font> suddenly become a potentially crashing operator violates the expectation that <font face="Menlo" class=""><span style="font-size: 11px;" class="">?</span></font> is an indication of safety.</div><div><br class=""></div><div>On the other hand, the existing semantics of Swift are that <font face="Menlo" class=""><span style="font-size: 11px;" class="">!</span></font> is always dangerous, so making <font face="Menlo" class=""><span style="font-size: 11px;" class="">!!</span></font> be the a potentially crashing operator is much more consistent with the language.</div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><div class="">There is no need for `!!` because it will fade in the future. If you think of `Never` as a bottom type now then `??` will already make total sense. The default value for T from rhs might be T or Never.&nbsp;</div></div></div></blockquote><div><br class=""></div><div>I respectfully disagree with your absolute position on this topic. Even with <font face="Menlo" class=""><span style="font-size: 11px;" class="">Never</span></font> as a bottom type in the future, it would <i class="">still</i>&nbsp;be more convenient for me to type:</div><div><br class=""></div><div><font face="Menlo" class=""><span style="font-size: 11px;" class="">let last = array.last !! “Array must be non-empty"</span></font></div><div><br class=""></div><div>… than it ever would be to type:</div><div><br class=""></div><div><font face="Menlo" class=""><span style="font-size: 11px;" class="">let last = array.last ?? fatalError(“Array must be non-empty”)</span></font></div><div><br class=""></div><div>Dave</div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><div class=""><br class=""></div><div class="">@erica: the rhs argument should be called something like `noreturnOrError` and not `defaultValue`. And we should keep in mind that when Never becomes the bottom type we have to remove that overload from stdlib, because otherwise it will be ambiguous.&nbsp;</div><div class=""><br class=""></div><div class="">---</div><div class=""><br class=""></div><div class="">On the other hand if we tackle a different operator then we should rething the 'default value operator' because the second ? signals an optional but not a non-optional or an inplicit unwrapped operator. In that case I personally thing ?! would make more sense. Unwrap or (non-optional | IUO | trap/die)<br class=""> <br class=""><div class="bloop_sign"><div style="font-family:helvetica,arial;font-size:13px" class="">--&nbsp;<br class="">Adrian Zubarev<br class="">Sent with Airmail</div></div><p class="gmail_quote" style="">Am 28. Juni 2017 um 18:13:18, Tony Allevato via swift-evolution (<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>) schrieb:</p> <blockquote type="cite" class="gmail_quote"><span class=""><div class=""><div class=""></div><div class="">


<title class=""></title>


<div class="">
<div class="">It's hard for me to articulate, but "foo !! message" feels a
little too much like a Perl-ism for my taste. Objectively that's
not a great criticism on its own, but I just don't like the "smell"
of an operator that takes a value on one side and a string for
error reporting purposes on the other. It doesn't feel like it fits
the style of Swift. I prefer a version that makes the call to
fatalError (and thus, any other non-returning handler) explicitly
written out in code.<br class="">
<br class="">
So, if the language can already support this with ?? and
autoclosure/Never as was shown above, I'd rather see that added to
the language instead of a new operator that does the same thing
(and is actually less general).</div>
</div>
<div class="">
<div class=""><br class="">
<div class="gmail_quote">
<div class="">On Wed, Jun 28, 2017 at 8:52 AM Jacob Williams via
swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;
wrote:<br class=""></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" class="">
<div class="">I feel that the !! operator would be necessary for indicating
that if this fails then something went horribly wrong somewhere and
we should throw the fatalError. This allows the inclusion of
optimizations using -Ounchecked and is clear that this is an
operation that could result in a runtime error just like force
unwrapping.</div>
<div class=""><br class=""></div>
<div class="">If we want code clarity and uniformity, then I think !! Is
much better than ?? because it goes right along with the single !
Used for force unwrapping. However, this does depend on if the
operator would be returning some kind of error that would cause the
program to exit.</div>
<div class=""><br class=""></div>
<div class="">I think the ?? operator should not cause a program to exit
early. It goes against optional unwrapping principles. I think code
could get very confusing if some ? would return nil/a default
value, and others would be causing your program to crash and exit.
The ? operators should always be classified as safe
operations.</div>
</div>
<div style="word-wrap:break-word" class="">
<div class=""><br class="">
<div class="">
<blockquote type="cite" class="">
<div class="">On Jun 28, 2017, at 9:41 AM, Ben Cohen via swift-evolution
&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:</div>
<br class="m_2866777249939610229m_1922728200947037084Apple-interchange-newline">

<div class="">
<div style="word-wrap:break-word" class=""><br class="">
<div class="">
<blockquote type="cite" class="">
<div class="">On Jun 28, 2017, at 8:27 AM, David Hart via swift-evolution
&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:</div>
<br class="m_2866777249939610229m_1922728200947037084Apple-interchange-newline">

<div class=""><span style="font-family:Helvetica;font-size:12px;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;float:none;display:inline!important" class="">
Count me in as a strong proponent of ?? () -&gt; Never. We don't
need to burden the language with an extra operator just for
that.</span><br class="m_2866777249939610229m_1922728200947037084Apple-interchange-newline">
</div>
</blockquote>
</div>
<br class="">
<div class="">You could say the same about ??</div>
<div class=""><br class=""></div>
<div class="">The concern that an additional operator (and one that, IMO,
fits well into existing patterns) is so burdensome seems way
overweighted in this discussion IMO.&nbsp;</div>
<div class=""><br class=""></div>
<div class="">Adding the operator, and encouraging its use, will help foster
better understanding of optionals and legitimate use of
force-unwrapping in a way that I don’t think `?? fatalError`
could.</div>
<div class=""><br class=""></div>
<div class=""><br class=""></div>
</div>
_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
</div>
</blockquote>
</div>
<br class=""></div>
</div>
_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" target="_blank" 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/mailman/listinfo/swift-evolution</a><br class="">
</blockquote>
</div>
</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="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></div></span></blockquote>

</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="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>