<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>I never liked "!" because it can so easily be overlooked, so I'm fine with "not"</div><div><br></div><div>-Thorsten</div><div><br>Am 15.12.2015 um 16:01 schrieb Marc Knaup via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>>:<br><br></div><blockquote type="cite"><div><div dir="ltr">I'm uncertain but it's definitely worth considering.<div><br><div>I also think that it's weird at the moment since in most cases the exclamation mark is now something dangerous.</div></div><div>I also had a couple of bugs in my code because the operator is too easy to miss and the negation was not or no longer intended.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 15, 2015 at 3:11 PM, Bruno Berisso via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div>I'm really used to negate logical expressions with this operator but it never feels confortable to me. If I need to negate some complex expression sometimes I prefer to write a temporal variable and then negate that with <b>!</b> because I fear than others, or myself, could overlook it and cause confusion.</div><div><br></div><div>Now that Swift use the same operator to force the unwrap of optional values it becomes even worse.</div><div><br></div><div>Consider this examples:</div><div><br></div><div>if someOptionalValue != nil {</div><div> ...</div><div> if !(otherBoolValue && someOptionalValue! > 0) {</div><div> ...</div><div> }</div><div>}</div><div><br></div><div>Or even worse, what happen when negating Optional<Bool> values?</div><div><br></div><div>//Best case</div><div>if let value = optionalBool where !value {</div><div> ...</div><div>}</div><div><br></div><div>//Worse case</div><div>if !optionalBool! {</div><div> ...</div><div>}</div><div><br></div><div>Now what happen with this examples if we instead use a <b>not</b> operator:</div><div><br></div><div><div>if someOptionalValue != nil {</div><div> ...</div><div> if not (otherBoolValue && someOptionalValue! > 0) {</div><div> ...</div><div> }</div><div>}</div><div><br></div><div>if let value = optionalBool where not value {</div><div> ...</div><div>}</div><div><br></div><div>if not optionalBool! {</div><div> ...</div><div>}</div></div><div><br></div><div>I'm not sure if <b>not</b> is the right path here but I really want to improve the <b>!</b> to something more clear at a glance and that doesn't have different behaviour depending where it appears in an expression.</div><div><br></div><div>Thanks,</div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=6ZGE61OxINd5lLe2xYh9Ku-2BXbixWNr2nvfzp2IB1sZiUK6bWllvEAW1nr0HIeUahbgxRTKL9Y15l4Vtk8B72J-2BZQXJRCmf-2B4azoEnD6bnKV5S7-2Bku6A5xCXRoBAJeopBSkIQTbcN8g2-2BePsmHiVp3qgaUWk2nUP-2Fwoi93r6jvWfWg3Kj7XQklxjLvSGlfXuW96qy459-2BFNfdsiHQ4a0wF02qeVSIfpWOCKLxzuwTvTk-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important">
<br>_______________________________________________<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/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=1MXK54sosN3xru3iYcLt0oBZ2w20i49gyogXctgrspfMFwrVRDWnp3SBlnmpiDJ2IPz1bpXj-2F-2FVDGTssxIlHdlwLQpJAF7XL-2BxLhN50R0SsGyeJbyhpMwhOI8YIxaDmFVAqnMfedGzpulILShC5w5h3GVRoLuo37v55Pdiw-2F395GCnhlKDY9-2BnqOMXf99Id9j9ZeJhPk1aJsMJl1cFwmYsoQQosoc2JUtoiYYOLbcwo-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;">
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>