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

Haravikk swift-evolution at haravikk.me
Wed Mar 2 16:36:08 CST 2016

> On 2 Mar 2016, at 12:20, Tino Heth via swift-evolution <swift-evolution at swift.org> wrote:
> 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).

Firstly; you seem to have picked the worst possible attribute name. People seem to be favouring a @discardable attribute on the return type itself, so something like:

	func myFunction() -> @discardable String { … }

The question really is whether you think functions with intentionally discardable results are in the minority or not. In my experience they’re pretty uncommon, and designed to be usable in that way, in which case it makes sense for an explicit declaration to clarify that intent, both to the compiler to ensure that it isn’t seen a potential mistake, but also to developers in documentation, where a return value can be clearly marked as discardable.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160302/d3a5f564/attachment.html>

More information about the swift-evolution mailing list