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

David Owens II david at owensd.io
Wed Mar 2 14:13:39 CST 2016


It feels like there are three basic groups of APIs:

An API that returns a result that should be used.
An API that returns a result that can be used.
An API that returns no result (void).

I completely agree that if a result is returned, the intent of the API is more than likely expecting the caller to use it.

My primary preference is to just say that's the way it is. I don't particular like any of the attributes. Also, we have a mechanism to discard the result already:

let _ = discardableResult()

For resiliency, is adding a `@discardable` attribute a breaking change? Removing it?

So +1 on changing the default to always warn on unused results, -1 on implementing an attribute to allow API designers to mark it as discardable; I'd rather have a `void` overload that did it instead an attribute.

-David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160302/7167ca2e/attachment.html>


More information about the swift-evolution mailing list