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

2015-12-22 Thread Kevin Ballard via swift-evolution
On Mon, Dec 21, 2015, at 11:17 PM, Brent Royal-Gordon wrote: > > And that brings to mind a second question: How about functions that are > > generic in their return type? For example, > > `withExtendedLifetime(_: T, _: T throws -> Result) rethrows -> > > Result`. The return type may

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

2015-12-21 Thread Kevin Ballard via swift-evolution
Also, one question that I haven't seen come up yet: Would this behavior change affect closures? I'm inclined to say that closures that declare a type explicitly should get this behavior (because it's easy to add @allow_unused_result to those), but closures whose type is inferred should not

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

2015-12-19 Thread Kenny Leung via swift-evolution
Hi All. Being naive here (also very difficult to say this clearly and succinctly), but why is this the choice of the writer of the function rather than the person using the function? That is, I would think that if I were worried about unused return results in my code, I would have some kind

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

2015-12-19 Thread Frederick Kellison-Linn via swift-evolution
The idea is that the writer of the function is the one who can decide whether or not the result of their function can be safely ignored. Imagine you wrote a function in Swift: func times(x: Int, y: Int) -> Int { return x * y; } At the point of writing this function (though it may be a

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

2015-12-18 Thread Janosch Hildebrand via swift-evolution
I am also strongly in favor of this proposal. There are probably enough valid use cases for a @suppress_unused_warning but personally I don't think pop() is a great example. I think a second method à la dropFirst/Last/... that returns Void would be better at communicating intent and allows

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

2015-12-18 Thread Janosch Hildebrand via swift-evolution
> On 18 Dec 2015, at 23:23, Dave Abrahams wrote: >> >> I think a second method à la dropFirst/Last/... that returns Void would be >> better at communicating intent and allows pop() to retain the warning. > > Those are non-mutating methods that don’t return Void, FWIW.

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

2015-12-18 Thread Dave Abrahams via swift-evolution
> On Dec 18, 2015, at 2:01 PM, Janosch Hildebrand via swift-evolution > wrote: > > I am also strongly in favor of this proposal. > > There are probably enough valid use cases for a @suppress_unused_warning but > personally I don't think pop() is a great example. >