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

L. Mihalkovic laurent.mihalkovic at gmail.com
Sat May 28 01:14:48 CDT 2016


Golang has IMO successfully used this in their IF statement. Coming from a recent imersion into the language, it is not as distracting in real life code on a day to day basis, as it might seem to be when first seen in a spec. Considering the parallel with the swift guard, this is IMO a nice advancement.

On May 28, 2016, at 1:35 AM, 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 { ... }
> 
> This would obviously be a built-in `&&` separate from our existing, infix operator `&&`. (Well, unless we make `let` and `case` clauses return Bools in an `if` statement, and somehow teach the compiler that `&&` will return `false` if a binding fails.) But there is no ambiguity about the meaning of this code. It is obvious that both conditions have to succeed, and it is obvious that `z == 2` was not meant to be another optional binding. Honestly, in some ways it's more understandable than the status quo.
> 
>>    • Is the problem being addressed significant enough to warrant a change to Swift?
> 
> Maybe, if we have a good enough solution. I don't think this is it.
> 
>>    • Does this proposal fit well with the feel and direction of Swift?
> 
> I think it's kind of neutral, honestly.
> 
>>    • If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
> 
> Most languages I've used have `if` statements which take a simple boolean expression, so they don't face this problem.
> 
>>    • How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
> 
> Pretty much a glance.
> 
> -- 
> Brent Royal-Gordon
> Architechies
> 
> _______________________________________________
> 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