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

Tino Heth 2th at gmx.de
Wed Mar 2 06:20:58 CST 2016


> Macho posturing about how only bad programmers need safety is not helpful
I'm not arguing against safety at all — but safeguards sacrificing ease of use often open a new can of worms.
Swift is already quite "mothering" with its warnings, and I'd rather move some checks to a separate analyze-step than adding new ones (one example are the hints to replace "var" with "let", which are a constant distraction until I finally write the line with the change…)
It is fine to throw a warning for pure functions, and it is good practice to annotate methods that can be misinterpreted easily, but I'd rather trust in the developer discarding a result in most other situations.
The compiler can't know wether a method was called for its side effects, so I prefer to leave this decision to the human using it — he should know.

You may code in a different style as Andrey and I, but discardable return values are no anti-pattern, so I don't think they should be punished with a monstrosity like "@dont_warn_unused_result" (shiver).

- Tino

I myself break the most prominent programmer cliches easily (including the ability to cook quiche that has never seen a freezer ;-), but apparently, I should strive for more bluntness, as it greatly increases the chances for reactions...


More information about the swift-evolution mailing list