[swift-evolution] Make non-void functions @warn_unused_result by default
Matthew Johnson
matthew at anandabits.com
Thu Dec 10 17:28:00 CST 2015
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> wrote:
>
>
>> On 10 déc. 2015, at 15:58, Adrian Kashivskyy via swift-evolution <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
> https://lists.swift.org/mailman/listinfo/swift-evolution
More information about the swift-evolution
mailing list