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

Alex Hoppen alex at ateamer.de
Thu Feb 25 10:51:07 CST 2016


+1 for the proposal and @discardableResult

– Alex

> On 25 Feb 2016, at 16:49, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
> on Wed Feb 24 2016, Haravikk <swift-evolution-AT-haravikk.me <http://swift-evolution-at-haravikk.me/>> wrote:
> 
>>> On 24 Feb 2016, at 23:44, Janosch Hildebrand <jnosh at jnosh.com> wrote:
>>> 
>>> Thanks for the encouragement everyone! I’ll start drafting over the weekend.
>>> 
>>> With regard to the inverted attribute, that is definitely open to discussion.
>> 
>>> Other variants that had been mentioned previously include:
>>> 
>>> @suppress_unused_result - suggested by Adrian Kashivskyy
>>> @allow_unused_result - suggested by Kevin Ballard
>>> @ignoreresult - suggested by Brent Royal-Gordon
>>> 
>>> Also the aforementioned “Modernizing Attribute Case and Attribute
>>> Argument Naming” proposal[1] will also play into this discussion as
>>> well.
>>> 
>>> [1]
>>> https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160215/010510.html
>>> <https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160215/010510.html <https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160215/010510.html>>
>>> 
>>> - Janosch
>> 
>> While I like the brevity, I don’t think @ignoreresult is clear enough
>> on what it does, @optional_result (or ideally @optionalResult if
>> camel-case for attributes is accepted) is clearer I think if we want a
>> shortened two-word form. Or there’s Sean’s @discardable_result
>> alternative which is even clearer.
>> 
>> Otherwise @allow_unused_result is the best of the three word options I
>> think; @suppress_unused_result is a bit unclear as what you’re
>> actually suppressing is the compiler warning, as in most cases a
>> result will still be generated, it’s just not stored anywhere at the
>> call site.
> 
> @discardable_result is nice.  I kinda wish it were an annotation on the result
> type; then it could just be @discardable.
> 
> -- 
> -Dave
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution <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/76d017d5/attachment-0001.html>


More information about the swift-evolution mailing list