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

Chris Lattner clattner at apple.com
Wed Mar 2 22:16:31 CST 2016

> On Mar 2, 2016, at 4:13 PM, Brent Royal-Gordon <brent at architechies.com> wrote:
>> 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()
> Do you really want to require that for, say, `RangeReplaceableCollectionType.removeLast()`? Because that's what this implies.

I don’t get that.  If X.removeLast() returned a result, but also had an important side effect, I would expect it to be one of the (few but important) cases that would be marked with the @discardable attribute, so it would not produce a warning.

> I don't think that's a good idea. It would make the warning more noisy, which would ultimately make it meaningless.
>> For resiliency, is adding a `@discardable` attribute a breaking change? Removing it?
> If it has any resiliency implications at all, removing it would break. But I don't think it would; it merely controls a warning, and doesn't necessarily imply any change in semantics.

I can’t imagine any scenario where @discardable would impact resilience.


More information about the swift-evolution mailing list