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

Brent Royal-Gordon brent at architechies.com
Wed Mar 2 18:23:42 CST 2016

> 	• @attribute func f() -> T {}
> 	• func f() @attribute -> T {}
> 	• func f() -> @attribute T {} (I prefer this one)
> 	• @ func f() -> T | Void {}

I've taken the survey and registered my opinion, but I have to ask, what's the logic behind the `@attribute -> T` form? `throws` is in that position because it can be applied to Void functions, but Void functions are already discardable (or whatever we call it) and don't need this keyword.

Also, it occurs to me that we might want to create an opposite-meaning keyword (i.e. *do* warn if this value is ignored) and make the return values of `mutating` methods discardable by default, on the assumption that the side effect is the main purpose of calling them. That might run counter to the behavior we usually want, though, or it might just be too complicated to bother with.

Brent Royal-Gordon

More information about the swift-evolution mailing list