[swift-evolution] extend trailing closure rule

Erica Sadun erica at ericasadun.com
Wed Jun 8 17:30:57 CDT 2016

> On Jun 8, 2016, at 4:11 PM, Matt Neuburg via swift-evolution <swift-evolution at swift.org> wrote:
> Well, I guess I didn't pick a strong enough case. Try this one:
>        UIView.animate(withDuration:0.4, delay: 0, options: [.autoreverse]) {
>            self.view.backgroundColor = UIColor.red()
>        }
> That doesn't compile. I'm suggesting that it would be cool if it did. m.

Mid-call closure can mean one of several things:

1. Bad design
2. Multiple closures
3. Design before Swift / ObjC focused

To which:

1. Well, not sure that should be "fixed"
2. I think multiple closures should all be treated the same without trailing
3's a different kind of thing. I vaguely endorse having Cocoa request how it should be imported beyond the SE-0005 rules. 

We were kicking around some ideas on "how should defaults embetter" that this kind of relates to: https://gist.github.com/erica/3987ec54b8f4a580ae5fc18f4e9e7ca5 <https://gist.github.com/erica/3987ec54b8f4a580ae5fc18f4e9e7ca5>  In this example, I can see a rule of "if there's only one closure named animation, completion, etc, promote it to the last argument". Kind of.

-- E, dithery

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160608/d9315529/attachment.html>

More information about the swift-evolution mailing list