[swift-evolution] [Review] SE-0056: Allow trailing closures in `guard` conditions

Thorsten Seitz tseitz42 at icloud.com
Mon Apr 4 11:03:13 CDT 2016

> Am 04.04.2016 um 16:49 schrieb Jeremy Pereira via swift-evolution <swift-evolution at swift.org>:
>> On 3 Apr 2016, at 17:20, Haravikk via swift-evolution <swift-evolution at swift.org> wrote:
>> Although I use trailing closures a lot less now, I think I’m a +1 anyway for consistency’s sake.
>> I actually really like the idea of having trailing keywords in loops and if statements, these needn’t be required (except where a trailing closure is used) but for example it means I could do a fully natural language loop like:
>>    for eachValue in theValues do { … }
> This is actually kind of bizarre. Here we are trying to invent new syntax so that the trailing closure can be used in if/while conditions and for sequences. However, there is already a perfectly good syntax for putting closures in these positions: put the closure in the parentheses of the function call. Are people really so desperate to use trailing closures everywhere that we have to add new keywords to the language? I don’t think they are.

I agree.
While I'm a big proponent of trailing closures to create DSL like control constructs and prefer them over nesting closures within parentheses I don't think it is a good idea to mix such DSL like control constructs with existing control constructs as this would not increase readability but rather decrease it (compare e.g. the example given by Xiaodi).

Therefore I'm -1 on this proposal and think it's fine having to use parentheses instead of trailing closures in such cases.


More information about the swift-evolution mailing list