[swift-evolution] [DRAFT] Regularizing Where Grammar (was Re: Add a while clause to for loops)
Rob Norback
rnorback at gmail.com
Thu Jun 9 16:18:31 CDT 2016
Def like this change, but Erica I'm wondering what changed your mind about
the syntax since the last I read you still were concerned by the ambiguity
between filtering and exiting.
On Thu, Jun 9, 2016 at 1:54 PM Erica Sadun via swift-evolution <
swift-evolution at swift.org> wrote:
> On Jun 9, 2016, at 1:57 PM, Haravikk <swift-evolution at haravikk.me> wrote:
>
> I think the idea here is for a change from the first to the second of:
>
> for eachValue in theValues where eachValue.isOdd { … }
> for eachValue where eachValue.isOdd in theValues { … }
>
> I’m kind of split on this for a few reasons. The first is that it doesn’t
> ready quite as well plain like this, however I find it looks a bit better
> like:
>
> for (eachValue where eachValue.isOdd) in theValues { … }
>
>
>
> for eachValue where eachValue.isOdd in theValues { ... }
> for case .Some(let value) where value > 5 in theValues { ... }
>
> vs
>
> for eachValue in theValues where eachValue.isOdd {...}
> for case .Some(let value) in theValues where value > 5 { ... }
>
> It should be parseable without parens.
>
>
> Just to clarify that what we’re looking for in theValues is “eachValue
> where eachValue.isOdd”, though I could probably learn to read it like this
> without parenthesis. That said, parenthesis lines up nicely with assignment
> of tuples like:
>
> for (eachKey, eachValue where eachValue > 5) in theKeyValuePairs { … }
>
>
> for (eachKey, eachValue) where eachValue > 5 in theKeyValuePairs {... }
>
> The where clause is distinct from the pattern
>
> -- E
>
>
> _______________________________________________
> 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/14418acf/attachment.html>
More information about the swift-evolution
mailing list