[swift-evolution] /*Let it be*/ func() -> @discardable Bool {} /*Rather Than*/ @discardableResult func() -> Bool {}

Mike Kluev mike.kluev at gmail.com
Sat Oct 21 12:04:03 CDT 2017


> On 21 Oct 2017, at 17:06, Chris Lattner <clattner at nondot.org> wrote:
> 
> 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.

Very well said.

For that same reason “return void-expression” shall not be allowed (and not parsed as such in a multiline statement)?

override func viewDidLoad() {
    super.viewDidLoad()
    return

    someView = SomeView(frame: view.bounds)
    ....
}

Although it doesn’t fully solve the problem, as the two types may well be something other than void.

Mike



More information about the swift-evolution mailing list