[swift-evolution] [swift-evolution-announce] [Review] SE-0047 Defaulting non-Void functions so they warn on unused results
dsa.mls at icloud.com
Thu Mar 17 20:04:53 CDT 2016
> Le 17 mars 2016 à 06:50, Haravikk via swift-evolution <swift-evolution at swift.org> a écrit :
>> On 17 Mar 2016, at 09:27, Tino Heth via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> Have a look at http://www.martinfowler.com/bliki/FluentInterface.html <http://www.martinfowler.com/bliki/FluentInterface.html> for a good reason to keep "results" discardable.
> Ack, hit send before quoting this part to come back to it.
> I assume your point here is that having to add @discardableResult (or whatever) will lead to fluent interfaces becoming prone to the same mistakes that non-fluent interfaces currently have with @warn_unused_result.
> Perhaps we could add some kind of attribute to the type itself to allow for selection between the two behaviours?
> For example, we could use a different attribute in the style of:
If we go with something like this, we may want to also have a:
Which generate error for unused result, and a warning when assigning the result to _.
This could be useful for function which return allocated resources, which is a return code that should never be ignored even explicitly.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution