[swift-evolution] /*Let it be*/ func() -> @discardable Bool {} /*Rather Than*/ @discardableResult func() -> Bool {}
Chris Lattner
clattner at nondot.org
Sat Oct 21 11:06:38 CDT 2017
> On Oct 18, 2017, at 8:04 PM, Xiaodi Wu via swift-evolution <swift-evolution at swift.org> wrote:
>
> I am not sure this is entirely wise, for a few reasons.
>
> a) I sure don't know why you'd want to return `Void?`, but if you do, it doesn't follow that it should be discardable simply because `Void` is discardable. It may well be so, or it may be (for some odd reason) that it's the return type of a pure function that certainly shouldn't be discardable.
FWIW, I’d be pretty opposed to making Void? implicitly discardable. In the case of a generic function that returns T? where T can sometimes be void, the optional still carries information: perhaps about failure of the operation or something else. The reason that void and Never default to being ignored is that they are carry no information. Void? carries one important bit.
-Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171021/c7567a13/attachment.html>
More information about the swift-evolution
mailing list