[swift-evolution] Make non-void functions @warn_unused_result by default
Riley Testut
rileytestut at gmail.com
Thu Dec 10 17:35:30 CST 2015
My initial gut reaction is that I don’t mind this change happening, but I would much prefer using a @suppress_unused_result attribute than forcing the user to "let _ = “. The API designer should know whether the return value is necessary or not, and make it easy for the consumer to decide whether they want to use it or not.
> On Dec 10, 2015, at 3:30 PM, Adrian Kashivskyy via swift-evolution <swift-evolution at swift.org> wrote:
>
> Matthew, I actually like your idea better than using an opposite "@suppress_unused_result" attribute. In addition, it will even be easier to implement, since "let _" syntax is already supported in the language.
>
> Pozdrawiam – Regards,
> Adrian Kashivskyy
>
>> Wiadomość napisana przez Matthew Johnson <matthew at anandabits.com <mailto:matthew at anandabits.com>> w dniu 11.12.2015, o godz. 00:28:
>>
>> Why should unused results be acceptable? Why not require callers to explicitly throw away the result:
>>
>> let _ = funcReturningValueThatIsIgnored()
>>
>> Yes this is extra syntax, but it also makes it clear that the value was intended to be ignored and the function was only executed for side-effects.
>>
>>> On Dec 10, 2015, at 5:23 PM, Guillaume Lessard via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>>
>>>
>>>> On 10 déc. 2015, at 15:58, Adrian Kashivskyy via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>>>
>>>> I think non-void functions should warn about their return value being unused by default, thus eliminating the need to attribute them with @warn_unused_result.
>>>
>>> I strongly don’t like this idea. This being said, if it happens ann attribute that says "unused result are acceptable" must be created. Makes me wince.
>>>
>>> Guillaume Lessard
>>>
>>> _______________________________________________
>>> swift-evolution mailing list
>>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>
>
> _______________________________________________
> 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/20151210/6fc6c0b1/attachment.html>
More information about the swift-evolution
mailing list