<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="">+1 on making warn-unused-result the default.</div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On 02 Mar 2016, at 19:58, Gwendal Roué via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Some may import some foreign (yet valid) patterns like having the remove() function of a collection return the removed element (I didn’t have to look too far way: here is a lib with much hype theses days which does exactly that: <a href="https://github.com/lorentey/BTree/blob/master/Sources/BTree.swift#L507" class="">https://github.com/lorentey/BTree/blob/master/Sources/BTree.swift#L507</a>)<br class=""><br class="">See?<br class=""></div></div></blockquote></div><br class=""><div class="">
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px;"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px; font-size: 12px;"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">That doesn't seem like a great example because the very same library is making extensive use of <font face="Menlo" class="">@warn_unused_result</font> at places where it matters. <span style="text-align: -webkit-auto;" class="">So of course it has a </span><font face="Menlo" style="text-align: -webkit-auto;" class="">remove()</font><span style="text-align: -webkit-auto;" class=""> method with a discardable, yet unannotated, return type. What else could it do since we don't have any such attribute yet!</span></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><span style="text-align: -webkit-auto;" class=""><br class=""></span></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><span style="text-align: -webkit-auto;" class="">I'm sure BTree will be among the first to adopt the new `</span><font face="Menlo" style="text-align: -webkit-auto;" class="">@ignore_unused_result</font><span style="text-align: -webkit-auto;" class="">` or `</span><font face="Menlo" style="text-align: -webkit-auto;" class="">foo() -> @discardable Result</font><span style="text-align: -webkit-auto;" class="">` attribute, whichever we may choose if the proposal gets accepted.</span></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">There will surely be libraries with unannotated functions whose return type is intended to be discarded. Some of them will be in Objective-C, which might be worth considering in the proposal. I believe it's a self-fixing problem however. If people feel the libraries are clumsy to use with all the `<font face="Menlo" class="">_ = x.foobar()</font>` business, they'll file bug reports and the maintainers will just add the needed attribute that removes the need for explicitly discarding the result. That's a non-breaking change after all.</div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">PS. You don't need any `<font face="Menlo" class="">let</font>` when discarding the result. The underscore is enough.</div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">— Pyry</div></span></div></span></div></body></html>