<div dir="ltr">Agreed. That would only allow to disambiguate call with unused result, but would not solve this problem. Jordan pointed at it.<div>It would be consistent therefore to leave @discardableResult functions with usual non-Void functions.</div><div><br></div><div>- Anton</div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-04-27 12:01 GMT+03:00 Andrew Bennett <span dir="ltr">&lt;<a href="mailto:cacoyi@gmail.com" target="_blank">cacoyi@gmail.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I&#39;m happy to add `<span style="font-size:13px"><font face="monospace, monospace">@unusedResult</font></span>`, with a little more discussion. I&#39;m not sure when it would actually be used though.<div><span style="font-size:13px"><font face="monospace, monospace"><br></font></span></div>I&#39;m not sure if you can define both of these functions:<br><font face="monospace, monospace"><br></font><div><font face="monospace, monospace">   @unusedResult func example() -&gt; Int</font></div><div><span style="font-family:monospace,monospace">   func example() -&gt; Int</span></div><div><font face="monospace, monospace"><br></font></div><div>Either way, a method with <span style="font-family:monospace,monospace">@unusedResult</span> should probably have a different name to one without. <font face="monospace, monospace"><br></font><div><span style="font-size:13px"><font face="monospace, monospace"><br></font></span></div>You can define both of these functions:</div><div><br></div><div><div><font face="monospace, monospace">   @unusedResult func example() -&gt; Int</font></div><div><span style="font-family:monospace,monospace">   func example() -&gt; String</span></div><div><span style="font-size:13px"><font face="monospace, monospace"><br></font></span></div></div>However, if the methods return different non-void values they should probably have different names.<div><span style="font-size:13px"><font face="monospace, monospace"><br></font></span></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 26, 2016 at 11:57 PM, Антон Жилин <span dir="ltr">&lt;<a href="mailto:antonyzhilin@gmail.com" target="_blank">antonyzhilin@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">+1<div><br></div><div>&gt; Also, technically we can assign a value to Void function<div>This proposal will not disallow that. Just non-Void functions will be preferred when result is used.</div><div><pre style="white-space:pre-wrap;color:rgb(0,0,0)">array.sort(..) // mutating
let array2 = array.sort(..) // non-mutating, instead of array.sorted()</pre><pre style="white-space:pre-wrap;color:rgb(0,0,0)"><font face="arial, helvetica, sans-serif">I think, that&#39;s actually the best solution to mutating / non-mutating convention!</font></pre></div><div>Andrew, why not generalize this proposal to functions with @unusedResult?</div><div><br></div><div>In terms of &quot;precedence&quot; when result is used:</div><div>Non-Void &gt; @unusedResult &gt; Void (+warning)</div><div><br></div><div>When unused:</div><div>Void &gt; @unusedResult &gt; Non-Void (+warning)</div><div><br></div><div>- Anton</div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>