[swift-evolution] [swift-evolution-announce] [Review] SE-0047 Defaulting non-Void functions so they warn on unused results

Michel Fortin michel.fortin at michelf.ca
Thu Mar 17 09:30:29 CDT 2016

> What is your evaluation of the proposal?

I worry about imported libraries. I think the default is right for code that was written directly in Swift, but for C and Objective-C code that was written in discartable-by-default environment, the APIs were designed with discardable results that in mind.

I also think it is imperative that the attribute is put just before the return type. Placing the attribute near the return type helps with the discoverability of the feature, which is important. It also makes it easier not to forget the attribute when adding a return type, which will reduce annoyances later.

> Is the problem being addressed significant enough to warrant a change to Swift?
> Does this proposal fit well with the feel and direction of Swift?

Maybe, but I'm not sure. It might cause annoyances for people who aren't aware of the feature. Either they'll feel forced to use "_ = foo()" repeatedly (what the compiler will suggest to them), or they'll feel annoyed enough that they'll just remove the return value from the function. So whether this is a convenience or an inconvenience depends entirely on people's awareness of the feature.

> How much effort did you put into your review? A glance, a quick reading, or an in-depth study?

Followed the discussion, read the proposal. Also checked whether adding @warn_unused_result everywhere in my code where appropriate would find bugs: it didn't.

Michel Fortin

More information about the swift-evolution mailing list