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

Chris Lattner clattner at apple.com
Thu Dec 10 19:29:06 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.  

FWIW, since patterns can exist on the left side of an assignment - a common example would be "(x,y) = foo()", you don’t need the let.  This is sufficient:

	_ = funcReturningValueThatIsIgnored()

-Chris


More information about the swift-evolution mailing list