<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Modified accordingly:</div><div class=""><br class=""></div><div class=""><div class=""><i class="">Under this proposal, the Swift compiler emits a warning when any method or function that returns a non-void value is called without using its result. To suppress this warning, the developer must affirmatively mark a function or method, </i><i class="">allowing the result to be ignored. It can be argued that such an override is unnecessary as Swift offers a mechanism to discard the result:</i></div><div class=""><i class=""><br class=""></i></div><div class=""><i class="">```swift</i></div><div class=""><i class="">let _ = discardableResult()</i></div><div class=""><i class="">```</i></div><div class=""><i class=""><br class=""></i></div><div class=""><i class="">This proposal argues that while this workaround makes it clear that the consumption of the result is intentionally discarded, it offers no traceable intent as to whether the API designer meant for this use to be valid. </i><i class="">Forcing an attribute ensures the discardable return value use is one that has been considered and approved by </i><i class="">the API author.</i></div></div><div class=""><br class=""></div><div class="">-- E</div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 2, 2016, at 1:13 PM, David Owens II 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=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">It feels like there are three basic groups of APIs:<div class=""><br class=""></div><div class=""><ol class="MailOutline"><li class="">An API that returns a result that should be used.</li><li class="">An API that returns a result that can be used.</li><li class="">An API that returns no result (void).</li></ol><div class=""><br class=""></div><div class="">I completely agree that if a result is returned, the intent of the API is more than likely expecting the caller to use it.</div><div class=""><br class=""></div><div class="">My primary preference is to just say that's the way it is. I don't particular like any of the attributes. Also, we have a mechanism to discard the result already:</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">let _ = discardableResult()</font></div><div class=""><br class=""></div><div class="">For resiliency, is adding a `@discardable` attribute a breaking change? Removing it?</div></div><div class=""><br class=""></div><div class="">So +1 on changing the default to always warn on unused results, -1 on implementing an attribute to allow API designers to mark it as discardable; I'd rather have a `void` overload that did it instead an attribute.</div><div class=""><br class=""></div><div class="">-David</div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>