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

Erica Sadun erica at ericasadun.com
Thu Feb 25 15:18:43 CST 2016


There are two parts to this suggestion:

Part 1 decorates the return type, which may or may not be used. This makes a lot of sense to me. as the return type can also be treated as Void
Part 2 suggests @convenience. This is easily tweakable.

-- E


> On Feb 25, 2016, at 2:06 PM, Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org> wrote:
> 
>> I’d say that the cases where it’s ok to discard the result are when the result is not strictly part of the API, but provided because it could be useful to the caller. An attribute that would naturally describe this could be
>> 
>> @convenience
>> 
>> The first example that comes to mind is Dictionary.updateValue. The declaration could then become
>> 
>>    public mutating func updateValue(value: Value, forKey key: Key) -> @convenience Value?
> 
> @convenience reads really, really well, but I'm worried it might get confused with `convenience init`, which means something completely different.
> 
> -- 
> Brent Royal-Gordon
> Architechies
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

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


More information about the swift-evolution mailing list