With Swift 1.2 the `if` syntax became a lot more powerful but also inconsistent.
Simply said the `if` syntax looks like the following (ignoring Swift 2's new pattern matching):
if <preconditions>, <assignment conditions> where <postconditions> {
It's evaluated from left to right.
For example:
if a && b && ..., let c = d, e = f, ... where g && h && ... {
Here a more natural hypothetical example:
if ready && shouldRead, let file = file, reader = file.reader where reader.available && reader.hasData {
It's weird that first a comma and later the `where` keyword is used to separate conditions.
In both cases they don't mean anything else than "and".
I'd suggest a simpler and more consistent syntax like this:
if ready && shouldRead && let file = file, reader = file.reader && reader.available && reader.hasData {
As before it's evaluated from left to right and the intent is much clearer.
Assignment conditions could now appear anywhere within the whole condition as long as they've all been evaluated when the `if` clause succeeds (e.g. not mixing `let`/`var` and `||`).
So this should be possible:
if let a = a && b && let c = d {
while this shoult not be:
if let a = a && (b || let c = d) {
Additionaly we could simplify `let x = x` to just `let x`:
if let x, y {
instead of
if let x = x, y = y {
Applying all of the improvements we could simplify the following code:
if ready, let file = file, reader = file.reader where reader.hasData {
if let line = reader.readLine() where line == "test" {
to this:
if ready && let file, reader = file.reader && reader.hasData && let line = reader.readLine() && line == "test" {
What do you think?