What is your evaluation of the proposal?
I kinda like the look of it, but I'm not too sure it fits.
Is the problem being addressed significant enough to warrant a change to Swift?
— and —
Does this proposal fit well with the feel and direction of Swift?
First of all, does it make sense to reserve this new syntax to trailing closures? The increased convenience is often significant for closures because they often span several lines, but I can't figure out a reason why non-closure arguments are not permitted (other than as an attempt to present it as an extension of the current trailing closure syntax).
Taking @cukr's example, wouldn't it be nice to be able to write this:
BenchmarkInfo {
name: "AngryPhonebook.ASCII.Small"
runFunction: { angryPhonebook($0, ascii) }
tags: t
setUpFunction: { blackHole(ascii) }
}
or:
BenchmarkInfo(name: "AngryPhonebook.ASCII.Small") {
runFunction: { angryPhonebook($0, ascii) }
tags: t
setUpFunction: { blackHole(ascii) }
}
instead of this:
BenchmarkInfo(
name: "AngryPhonebook.ASCII.Small",
runFunction: { angryPhonebook($0, ascii) },
tags: t,
setUpFunction: { blackHole(ascii) })
I think what's going to happen is people will intuitively try it by themselves and wonder why it works for some parameters and doesn't for others.
If we believe this syntax is good for closures, then it should also be good for any function argument that needs to live on its own line. Restricting it to only trailing closures makes little sense to me.
Of course, allowing comma-less calls would achieve practically the same thing and be less disruptive, at practically zero learning cost. I think this would be preferable. Example:
BenchmarkInfo(
name: "AngryPhonebook.ASCII.Small"
runFunction: { angryPhonebook($0, ascii) }
tags: t
setUpFunction: { blackHole(ascii) }
)
or
BenchmarkInfo(name: "AngryPhonebook.ASCII.Small"
runFunction: { angryPhonebook($0, ascii) }
tags: t
setUpFunction: { blackHole(ascii) }
)
The only reason to go with braces would be to avoid closing parens on their own line. Maybe that's worth it, but I'm not too sure.
If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
N/A
How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
Read the proposal and the discussion thread.