[swift-evolution] Make non-void functions @warn_unused_result by default

Joe Groff jgroff at apple.com
Thu Dec 10 18:01:20 CST 2015

> On Dec 10, 2015, at 3:28 PM, Matthew Johnson via swift-evolution <swift-evolution at swift.org> wrote:
> Why should unused results be acceptable?  Why not require callers to explicitly throw away the result:
> let _ = funcReturningValueThatIsIgnored()
> Yes this is extra syntax, but it also makes it clear that the value was intended to be ignored and the function was only executed for side-effects.  

There are a number of operations that sensibly return values, but are frequently used only for side effects, such as `pop` on a stack. I agree they're in the minority, and @warn_unused_result's polarity is backwards, but they're a big enough minority that the inverse attribute is valuable.


More information about the swift-evolution mailing list