<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=""><div class="">By the way, the following:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> updateIfNeeded() -&gt;&nbsp;<span style="color: rgb(187, 44, 162);" class="">@convenience</span>&nbsp;<span style="color: rgb(79, 129, 135);" class="">Int</span></div></div><div class=""><br class=""></div><div class="">… can satisfy a protocol requirement like:</div><div class=""><br class=""></div><div class=""><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">func</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;updateIfNeeded()</span></div><div class=""><span style="font-family: Menlo; font-size: 11px;" class=""><br class=""></span></div><div class="">I’m no expert but … I love this!</div><div class=""><br class=""></div><div class="">R+</div><br class=""><div><blockquote type="cite" class=""><div class="">On 25 Feb 2016, at 11:54, Rudolf Adamkovič &lt;<a href="mailto:salutis@me.com" class="">salutis@me.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">+1 for @convenience attached to the return type.</div><div class=""><br class=""></div><div class="">Very, very clean solution.</div><div class=""><br class=""></div><div class="">R+</div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 25 Feb 2016, at 09:13, Nicola Salmoria 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=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I agree that the attribute should be attached to the return type instead that to the function.</div><div class=""><br class=""></div><div class="">I’d say that the cases where it’s ok to discard the result are when the result is not strictly part of the API, but provided because it could be useful to the caller. An attribute that would naturally describe this could be</div><div class=""><br class=""></div><div class="">@convenience</div><div class=""><br class=""></div><div class="">The first example that comes to mind is Dictionary.updateValue. The declaration could then become</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp;&nbsp;<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">public</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">mutating</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> updateValue(value: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Value</span>, forKey key: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Key</span>) -&gt; @convenience&nbsp;<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Value</span>?</div></div><div class=""><br class=""></div><div class="">Nicola</div><div class=""><br class=""></div>
&gt; &gt; @optional_result (or ideally @optionalResult if camel-case for attributes is accepted) is clearer I think if we want a shortened two-word form.<br class="">&gt; I don't like "optional" here because it falsely implies a connection with the Optional type.<br class="">&gt; <br class="">&gt; I do think, however, that this needs to be something very short—one or two words, not three or four. One way to trim words would be to attach the attribute to the return type; the position would imply that the keyword related to the return type, so the word "result" would be unnecessary:<br class="">&gt; <br class="">&gt; @ignoreUnusedResult mutating func removeLast() -&gt;Element<br class="">&gt; mutating func removeLast() -&gt;@ignoreUnused Element<br class="">&gt; <br class="">&gt; That might be a little strange, though—we don't currently have any attributes in that position.<br class="">&gt; <br class="">&gt; Another way to make this shorter is to try to find an adjective which implies *why* we can ignore the result—that is, because it isn't important. The problem is that most such adjectives are either compound words:<br class="">&gt; <br class="">&gt; @unimportantResult mutating func removeLast() -&gt;Element<br class="">&gt; mutating func removeLast() -&gt;@unimportant Element<br class="">&gt; <br class="">&gt; @discardableResult mutating func removeLast() -&gt;Element<br class="">&gt; mutating func removeLast() -&gt;@discardable Element<br class="">&gt; <br class="">&gt; Or they're uncommon words people may need to look up:<br class="">&gt; <br class="">&gt; @banalResult mutating func removeLast() -&gt;Element<br class="">&gt; mutating func removeLast() -&gt;@banal Element<br class="">&gt; <br class="">&gt; Actually, I can think of one word in the latter category that many programmers *do* know:<br class="">&gt; <br class="">&gt; @trivialResult mutating func removeLast() -&gt;Element<br class="">&gt; mutating func removeLast() -&gt;@trivial Element<br class="">&gt; <br class="">&gt; --<br class="">&gt; Brent Royal-Gordon<br class="">&gt; Architechies<br class="">&gt; <br class="">&gt; <br class="">&gt; <br class="">&gt;<span class="Apple-converted-space">&nbsp;</span>

</div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></body></html>