[swift-evolution] [swift-evolution-announce] [Review] SE-0099: Restructuring Condition Clauses

Erica Sadun erica at ericasadun.com
Fri May 27 19:00:44 CDT 2016


On May 27, 2016, at 5:35 PM, Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org> wrote:
> 
>> 		https://github.com/apple/swift-evolution/blob/master/proposals/0099-conditionclauses.md
> 
>> 	• What is your evaluation of the proposal?
> 
> Oof.
> 
> I am not a fan of this syntax. `;` reads very strongly as a statement ender to me, and yet at the same time, it's still visually quite close to `,`. My first impression was that the proposal had an embarrassing typo in the very first example.
> 
> My suggestion would be to reuse our normal && operator:
> 
> 	guard
> 		x == 0 &&
> 		let y = optional &&
> 		z == 2
> 		else { ... }


In theory because if/guard/when create a mini scope, this might be possible to use in this context but I'll defer to Chris to reply to the issue of whether it's a better separator. Keep in mind that the proposal doesn't update the grammar for each of the conditions so the following is possible

guard
  x == 0 && a == b && c == d &&
  let y = optional, w = optional2, v = optional 3 &&
   z == 2
else { ... }

Figuring out where to break the first line into expression and into condition (after the `d`) could be very challenging to the compiler.

-- Erica



More information about the swift-evolution mailing list