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

Chris Lattner clattner at apple.com
Sat May 28 12:32:11 CDT 2016


> On May 28, 2016, at 1:10 AM, David Hart via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Yet another alternative: would it be possible to disallow commas as variable declaration separators and use them for condition clause separators again:
> 
> let a = 4, b = 8 // becomes illegal and requires to separate them on two lines
> 
> if a > 4, let c = foo(), let d = bar(), c != d { // now comma is not ambiguous anymore
> }

The ambiguity is between “case” and “let” conditions, specifically because “case” takes a pattern, and “let” is a valid pattern:

guard (pattern1) = expr1, let x = expr2 else

can be:

guard (pattern1) = expr1, let (x) = expr2 else

or:

guard (pattern1) = expr1, (let x) = expr2 else

-Chris


More information about the swift-evolution mailing list