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

Thorsten Seitz tseitz42 at icloud.com
Sat May 28 14:07:00 CDT 2016


What about requiring `let` before each binding and `case` before each pattern?

guard case let x = a, case let y = b, let z = c, x == y else { … }

Now `let z = c` can only be a let-binding and not a pattern matching clause.

-Thorsten


> Am 28.05.2016 um 19:32 schrieb Chris Lattner via swift-evolution <swift-evolution at swift.org>:
> 
> 
>> 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
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list