[swift-evolution] [Accepted with Revision] SE-0099 Restructuring Condition Clauses

Brandon Knope bknope at me.com
Wed Jun 8 23:47:05 CDT 2016

I am deeply saddened that a little part of character is lost in swift with the removal of where (imo). But I can be happy that ; is not being used I guess. 

My question: what is/was the rationale for adding where to swift 2? We seem to just be removing it everywhere now (or at least the proposals will be incoming)


Sent from my iPad

> On Jun 8, 2016, at 9:47 PM, Joe Groff via swift-evolution <swift-evolution at swift.org> wrote:
> The review of SE-0099 "Restructuring Condition Clauses" ran from January 13...18, 2016. The proposal has been accepted with revision for Swift 3. There was near unanimous agreement that the Swift 2 grammar was inconsistent and ambiguous and should be changed; most of the disagreement centered on how. Many alternatives were discussed, including the following:
> - The proposal as written suggests using ';' or newline as a separator. To many people, this looked heavy, and it's also inconsistent with the rest of the language, which never otherwise used semicolon as an intra-statement separator (except in the defunct for;; loop).
> - Introducing a keyword separator, such as using 'where' everywhere or introducing a new 'and' keyword, is also bulky and either reads poorly or requires stealing new keywords.
> - Some commenters suggested using '&&' for consistency with simple boolean conditions. This isn't workable due to precedence issues.
> - The ambiguities arise from the fact that there are comma-separated lists within comma-separated lists—within the list of conditions, each 'case' or 'let' condition can have multiple declarations. If we eliminated this feature, so that every 'case' or 'let' condition had to start with 'case' or 'let', the ambiguity is resolved, and comma can remain the condition separator. This does break consistency with non-conditional 'let' declarations and case clauses in 'switch' but is otherwise workable.
> Of these alternatives, the core team found the last one to be the best choice. 'case' and 'let' conditions should each specify a single declaration, comma should remain the condition separator, and the 'where' keyword can be retired from its purpose as a boolean condition introducer. Some code becomes more verbose, but in common formatting patterns, it aligns more nicely, as in:
> 	guard
> 	  let x = foo(),
> 	  let y = bar(),
> 	  let z = bas(),
> 	  x == y || y == z else {
> 	}
> and though it breaks commonality between 'let' conditions and 'let' declarations, it's more important to preserve higher-level consistency throughout the language in how components of expressions and statements are separated. Thanks everyone for the discussion, and thanks Erica and Chris for the proposal! Since, aside from the approved syntax, the fundamental thrust of the proposal remains the same, Chris has volunteered to revise it to be in line with the approved decision.
> -Joe
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160609/56b4ad2b/attachment.html>

More information about the swift-evolution mailing list