[swift-evolution] [Review] SE-0047 Defaulting non-Void functions so they warn on unused results

Andrey Tarantsov andrey at tarantsov.com
Thu Mar 24 16:34:33 CDT 2016


>> The new default is better for:
>> 
>> - (A) classes that provide both mutating and non-mutating methods;
>> - (B) methods where forgetting to use the result produces a bug (a
>> download task that needs to be resumed, an alert that needs to be
>> displayed, a listener that needs to be stored somewhere, etc).
> 
> To be clear, the mistake this warning prevents is the unintentional call
> to a non-mutating method when one thinks one is mutating the receiver.
> This scenario can arise independently of A or B.

Sure. Although if a type only has mutating or non-mutating methods, but not both, the mistake will probably be immediately apparent, so the diagnostic doesn't win you much (except maybe in a newbie learning environment, which is an important use case as well).

A.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160325/202dfda5/attachment.html>


More information about the swift-evolution mailing list