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

Taras Zakharko taras.zakharko at uzh.ch
Thu Jun 9 03:43:06 CDT 2016


A concern that I have with this is that comma seems to get inconsistent treatment in the language. In conditionals, commas clearly represent conjunctive clauses. However, the core team has also argued (review of SE-0095) that usage of comma implies disjunction and proposes that ‚&‘ is used for specifying intersection (conjunction) of types. So which is it? If we want to be 100% consistent, we should either adopt commas as conjunction through the language, or, use &/&& for conjunction. Personally, I have no problems accepting commas as conjunction.

— Taras


> On 09 Jun 2016, at 03:47, 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/3dbfbfd6/attachment.html>


More information about the swift-evolution mailing list