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

Christopher Kornher ckornher at mac.com
Tue May 31 14:32:14 CDT 2016

> On May 31, 2016, at 1:00 PM, Erica Sadun via swift-evolution <swift-evolution at swift.org> wrote:
>> On May 31, 2016, at 12:52 PM, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
>> These lines of reasoning are what have compelled me to conclude that `where` might not be salvageable.
> To which, I'd add: `where` suggests there's a subordinate and semantic relationship between the primary condition and the clause. There's no way as far as I know this to enforce it in the grammar and the proposal allows both clauses to be stated even without the connecting word.

OK. I am naive enough to try to informally define a rule that would make “where” required and cover all (?) cases in the proposal:

‘where’ is required after an if-let for any clause involving a variable or constant defined in that 'if let. All boolean expressions after the ‘where’ must reference at least one of constants defined by the ‘if let'


let a = a, b=b where b > 10 && a > 5 && b> a

Not allowed:
let a = a
let b = b where b > 10 && a > 5
b > a

let a = a
let b = b where b > 10
a > 5
b > a

This requires the use of commas because all inter-related ‘if let’ constants must be associated with a single ‘where'

This makes the use of ‘&&’ more natural, since everything to the right of “where” is a boolean expression

The formal grammar is left as an exercise :)

The downside:

	I would not have to answer all the ‘Why won’t this compile?’ questions on stack overflow. Of course, I would not want to do that for the current syntax, either.

> You could make a vague argument, I suppose, for renaming `where` to `when` but all in all, even killing `where` we benefit with better expressive capabilities and a simpler grammar.
> -- E
> _______________________________________________
> 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