[swift-evolution] [DRAFT] Regularizing Where Grammar (was Re: Add a while clause to for loops)
Thorsten Seitz
tseitz42 at icloud.com
Fri Jun 10 15:15:03 CDT 2016
-1
> Am 10.06.2016 um 21:10 schrieb Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org>:
>
> if case .some(let Point.cartesian(x, y)) where x < y = json["rect"]?["origin"].flatMap(.init(rawValue:)) { … }
This: `where x < y = json[…]` is *very* unreadable and probably unparseable as it is missing a delimiter between the boolean expression and the expression behind the assignment operator. And I do not count the assignment operator as a sufficient delimiter.
I’ll give the following counterargument against this shuffling around of `where` or trying to eliminate it:
if case .some(let x) = someExpression where x > 0
for x in xs where x > 0
These are actually very consistent in their grammar when you look at it like follows:
<target> <assignment op> <source> where <condition>
if case .some(let x) = someExpression where x > 0
target: `case .some(let x)`
assignment op: `=`
source: `someExpression`
condition: `x > 0`
for x in xs where x > 0
target: `x`
assignment op: `in`
source: `xs`
condition: `x > 0`
That is I’m arguing the `where` grammar is already quite regular and should not be changed. And yes, I’d like to have `where` back in `case`. And `let`.
-Thorsten
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160610/442afc2a/attachment.html>
More information about the swift-evolution
mailing list