<div dir="ltr"><div>I think <font face="monospace, monospace">@warn_unused_result</font> is already present on <font face="monospace, monospace">==</font>, at least for Bool in Swift 2.1.1.</div><div><br></div><div>For example:</div><div><br></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div><font face="monospace, monospace">$ swift --version</font></div><div><font face="monospace, monospace">Apple Swift version 2.1.1 (swiftlang-700.1.101.15 clang-700.1.81)</font></div><div><font face="monospace, monospace">Target: x86_64-apple-darwin15.2.0</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">$ cat test.swift </font></div><div><font face="monospace, monospace">var a = true</font></div><div><font face="monospace, monospace">let b = false</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">func doStuff() {</font></div><div><font face="monospace, monospace"> a == b</font></div><div><font face="monospace, monospace">}</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">$ swift test.swift</font></div><div><font face="monospace, monospace">test.swift:5:5: warning: result of call to '==' is unused</font></div><div><font face="monospace, monospace"> a == b</font></div><div><font face="monospace, monospace"> ^</font></div></div><div><br></div></blockquote></div><div>Warnings aren't shown in Playgrounds or in the REPL, though, so if you're running code there you won't see it.<br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 12, 2016 at 1:01 PM, Andrew Bennett 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">I'm +1 on <span style="font-size:13px">@warn_unused_result, does that need a proposal or is a PR sufficient?</span></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Tue, Jan 12, 2016 at 7:45 AM, Joe Groff via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div style="word-wrap:break-word"><span><br><div><blockquote type="cite"><div>On Jan 11, 2016, at 12:39 PM, Jared Sinclair via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br><div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px">Consider the following:</div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><br></div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><div style="margin:0px"><font face="Courier" color="#9437ff">protocol Updatable {</font></div><div style="margin:0px"><font face="Courier" color="#9437ff"> func update(state: Bool)</font></div><div style="margin:0px"><font face="Courier" color="#9437ff">}</font></div><div style="margin:0px"><font face="Courier" color="#9437ff"><br></font></div><div style="margin:0px"><font face="Courier" color="#9437ff">class Thing: Updatable {</font></div><div style="margin:0px"><font face="Courier" color="#9437ff"> private var enabled = false</font></div><div style="margin:0px"><font face="Courier" color="#9437ff"> </font></div><div style="margin:0px"><font face="Courier" color="#9437ff"> func update(state: Bool) {</font></div><div style="margin:0px"><font face="Courier" color="#9437ff"> self.enabled == state</font></div><div style="margin:0px"><font face="Courier" color="#9437ff"> }</font></div><div style="margin:0px"><font face="Courier" color="#9437ff">}</font></div><div style="margin:0px"><br></div><div style="margin:0px">The obvious intention is to set<span> </span><font color="#9437ff" face="Courier">self.enabled</font><span> </span>to the incoming value of<span> </span><font color="#9437ff" face="Courier">state</font>. However, it’s easy to accidentally type a second equals sign. The effect of this typo is <font color="#9437ff" face="Courier">self.enabled</font> is never updated, leading to a run-time bug that could be difficult to diagnose. </div><div style="margin:0px"><br></div><div style="margin:0px">This typo doesn’t generate any errors or warnings. I can’t think of a valid reason to use the equals function outside of comparisons. If the compiler instead treated this typo as an error, the mistake would be trivial to identify and fix:</div></div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="margin:0px"><font face="Courier" color="#9437ff">protocol Updatable {</font></div><div style="margin:0px"><font face="Courier" color="#9437ff"> func update(state: Bool)</font></div><div style="margin:0px"><font face="Courier" color="#9437ff">}</font></div><div style="margin:0px"><font face="Courier" color="#9437ff"><br></font></div><div style="margin:0px"><font face="Courier" color="#9437ff">class Thing: Updatable {</font></div><div style="margin:0px"><font face="Courier" color="#9437ff"> private var enabled = false</font></div><div style="margin:0px"><font face="Courier" color="#9437ff"> </font></div><div style="margin:0px"><font face="Courier" color="#9437ff"> func update(state: Bool) {</font></div><div style="margin:0px"><font face="Courier" color="#9437ff"> self.enabled == state // Error: `==` may not be used outside of comparisons</font></div><div style="margin:0px"><font face="Courier" color="#9437ff"> }</font></div><div style="margin:0px"><font face="Courier" color="#9437ff">}</font></div></div></div></blockquote><br></div></span><div>If it isn't already, the implementation of `==` ought to be marked with the `@warn_unused_result` attribute, which will give you a warning if the result is ignored. We're discussing making warn_unused_result the default behavior in another thread.</div><div><br></div><div>-Joe</div><br>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=pQw7h83fWt3LLbgkfL4TSUL0weaZnVFZxDe5GShw4uTPUNX5LE7jlGGN0y-2FR9uWwM2b25CU2dU2RBKnYAFVo3GJ33KcCUpBRwqV0Rx05iN-2BE8g7ACc-2FG6H-2BrYpIZuFpm6bhMTZX1inQMz2PJuDO-2BW7lVTHl921yRUaCbu10eXArNm9A9fHCRLGydVzxNtv5rBDr7v2x9OYGRjGrLrdLnJPSXuHDG8RJ9VPpCo64SaqI-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">
</div>
<br></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>
<br></blockquote></div><br></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=jcsQZDjngJCzOht1jfuLFUafDYRFGiKkaTW3jS9rsret9lodtK6Sd88DZ1ll8DDt5kOGeKLDvvKdkqxmGmlC2bqT21YSyl97CzrYWkj2BJttij-2B0iDMxA-2BjAkos-2Bf2dlNXwhhv5o-2BLvqjf1F-2FHYHaMA6evrsdvFuR3DAxm7aYcNx-2FqdtK3NPgXXz499fihn5UXOryYZamQe8dsPVxLmDRbFZFgUCWc001bnP0xeeL18-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><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><br></div><div><div dir="ltr" style="font-size:12.8000001907349px"><b style="font-size:small;background-color:transparent"><span style="color:rgb(53,217,144)"><font face="arial, helvetica, sans-serif">Alex Johnson</font></span><font color="#666666"> | Engineering Lead</font></b></div><div dir="ltr" style="font-size:12.8000001907349px"><b style="font-size:12.8000001907349px"><font color="#666666"><br></font></b></div><div dir="ltr" style="color:rgb(68,68,68);font-family:Arial,Verdana,sans-serif;font-size:12.8000001907349px"><div style="font-family:arial,sans-serif;color:rgb(34,34,34);font-size:12.8000001907349px"><b style="font-family:Arial;font-size:small;line-height:14.9499998092651px;white-space:pre-wrap"><a href="https://quickleft.com/" style="color:rgb(0,51,204)" target="_blank"><font color="#000000">Quick Left, Inc.</font></a></b></div><div style="font-family:arial,sans-serif;color:rgb(34,34,34);font-size:12.8000001907349px"><span style="color:rgb(0,0,0);font-family:Arial;white-space:pre-wrap;line-height:1.15;font-size:small;background-color:transparent"><b>Boulder </b></span><span style="font-size:12.8000001907349px"><font color="#999999"><b>|</b></font></span><b style="color:rgb(0,0,0);font-family:Arial;font-size:small;line-height:1.15;white-space:pre-wrap;background-color:transparent"> </b><b style="color:rgb(0,0,0);font-family:Arial;font-size:small;line-height:1.15;white-space:pre-wrap;background-color:transparent">Denver</b><font color="#999999" style="font-size:12.8000001907349px;background-color:transparent"><b style="font-family:Arial;font-size:small;line-height:1.15;white-space:pre-wrap;background-color:transparent"> </b><span style="font-size:12.8000001907349px"><b>|</b></span></font><b style="color:rgb(0,0,0);font-family:Arial;font-size:small;line-height:1.15;white-space:pre-wrap;background-color:transparent"> </b><b style="color:rgb(0,0,0);font-family:Arial;font-size:small;line-height:1.15;white-space:pre-wrap;background-color:transparent">Portland</b><font color="#999999" style="font-size:12.8000001907349px;background-color:transparent"><b><span style="font-family:Arial;font-size:small;line-height:1.15;white-space:pre-wrap;background-color:transparent"> </span><span style="font-size:12.8000001907349px">|</span></b></font><b style="color:rgb(0,0,0);font-family:Arial;font-size:small;line-height:1.15;white-space:pre-wrap;background-color:transparent"> San Francisco</b></div><div><font style="font-size:12.8000001907349px"><p style="line-height:1.15;font-size:12.8000001907349px;margin-top:0pt;margin-bottom:0pt"><span style="color:rgb(102,102,102);font-family:arial,sans-serif;font-size:12.8000001907349px;line-height:normal;background-color:transparent">1 (844) QL-NERDS</span></p><p style="font-size:12.8000001907349px;margin-top:0pt;margin-bottom:0pt"><font color="#666666" face="arial, sans-serif">@nonsensery</font></p><p style="font-family:arial,sans-serif;color:rgb(34,34,34);margin:0px"><br></p></font><p dir="ltr" style="line-height:1.15;font-size:12.8000001907349px;margin-top:0pt;margin-bottom:0pt"><span style="font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><a href="https://github.com/quickleft" style="color:rgb(0,51,204)" target="_blank"><img src="http://i.imgbox.com/MNlkdRf3.png" style="border:0px;padding:0px;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8000001907349px;line-height:normal;white-space:normal;vertical-align:middle!important" alt=""></a><a href="https://www.facebook.com/quickleft" style="color:rgb(0,51,204)" target="_blank"><img src="http://i.imgbox.com/mZ3v7rXp.png" style="border:0px;padding:0px;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8000001907349px;line-height:normal;white-space:normal;vertical-align:middle!important" alt=""></a><a href="https://twitter.com/quickleft" style="color:rgb(0,51,204)" target="_blank"><img src="http://i.imgbox.com/C2qj69cx.png" style="border:0px;padding:0px;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8000001907349px;line-height:normal;white-space:normal;vertical-align:middle!important" alt=""></a><a href="https://instagram.com/quick_left/" style="color:rgb(0,51,204)" target="_blank"><img src="http://i.imgbox.com/3kcv532Y.png" style="border:0px;padding:0px;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8000001907349px;line-height:normal;white-space:normal;vertical-align:middle!important" alt=""></a><a href="https://www.flickr.com/photos/quickleft" style="color:rgb(0,51,204)" target="_blank"><img src="http://i.imgbox.com/qrtOZXDo.png" style="border:0px;padding:0px;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8000001907349px;line-height:normal;white-space:normal;vertical-align:middle!important" alt=""></a><a href="https://vimeo.com/quickleft" style="color:rgb(0,51,204)" target="_blank"><img src="http://i.imgbox.com/lv7fDapY.png" style="border:0px;padding:0px;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8000001907349px;line-height:normal;white-space:normal;vertical-align:middle!important" alt=""></a></span></p><p dir="ltr" style="line-height:1.15;font-size:12.8000001907349px;margin-top:0pt;margin-bottom:0pt"><br></p><p dir="ltr" style="line-height:1.15;font-size:12.8000001907349px;margin-top:0pt;margin-bottom:0pt"><span style="font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font size="2"><a value="+13032425536" style="color:rgb(17,85,204);text-decoration:underline"></a></font></span></p><div style="font-family:arial,sans-serif"><span style="vertical-align:baseline;white-space:pre-wrap"><span style="color:rgb(53,217,144)"><font face="arial, helvetica, sans-serif" size="2"><b>What's it like to work with us? </b></font></span><font style="font-size:12.8000001907349px;font-family:Arial"><i style="color:rgb(0,0,0);font-family:arial,sans-serif;white-space:normal">TrainingPeaks, iTriage, and Ping Identity share their stories in this short video</i><i style="font-family:arial,sans-serif;white-space:normal"><font color="#500050"> </font><a href="https://vimeo.com/92286352" style="color:rgb(0,51,204)" target="_blank"><font color="#666666">A Client's View</font></a></i><span style="font-family:arial,sans-serif;white-space:normal"><font color="#666666">.</font></span></font></span></div></div></div></div></div></div></div></div>
</div>