[swift-evolution] Revisiting SE-0110

Robert Bennett rltbennett at icloud.com
Mon May 29 14:14:53 CDT 2017


> Well, from my point of view closure deserves some special syntax and rules.

Not sure I agree with that. Closures are just anonymous functions and so IMO their syntax should differ from function syntax as little as possible while retaining clarity. A named function call is written f(x, y) or g((x, y)). Immediately you know which has two arguments and which has a 2-tuple as its sole argument. I'm suggesting that for closures we merely transplant this syntax.

The only question (for me) is whether to include everything including the outer parentheses, or just everything between the parentheses. I would prefer to include everything including the outer parentheses because of the additional clarity (and IMO aesthetic quality) of making this syntax parallel the syntax enforced in SE 0066 and 0110:
let f1: (Int, Int) -> Double = { (x, y) in ...}
let f2: ((Int, Int)) -> Double = { ((x, y)) in ...}

The closures mirror their declarations, which (if implemented) would make it clear that the closure preambles are correct and will work as expected. It's just one fewer thing to have to think about.

> On May 29, 2017, at 2:42 PM, Vladimir.S <svabox at gmail.com> wrote:
> 
> Well, from my point of view closure deserves some special syntax and rules.


More information about the swift-evolution mailing list