<div dir="ltr">I'm happy to add `<span style="font-size:13px"><font face="monospace, monospace">@unusedResult</font></span>`, with a little more discussion. I'm not sure when it would actually be used though.<div><span class="" style="font-size:13px"><font face="monospace, monospace"><br></font></span></div>I'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() -> Int</font></div><div><span style="font-family:monospace,monospace"> func example() -> 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 class="" 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() -> Int</font></div><div><span style="font-family:monospace,monospace"> func example() -> String</span></div><div><span class="" 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 class="" style="font-size:13px"><font face="monospace, monospace"><br></font></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 26, 2016 at 11:57 PM, Антон Жилин <span dir="ltr"><<a href="mailto:antonyzhilin@gmail.com" target="_blank">antonyzhilin@gmail.com</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">+1<div><br></div><div>> 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'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 "precedence" when result is used:</div><div>Non-Void > @unusedResult > Void (+warning)</div><div><br></div><div>When unused:</div><div>Void > @unusedResult > Non-Void (+warning)</div><div><br></div><div>- Anton</div></div></div>
</blockquote></div><br></div>