[swift-evolution] [DRAFT] Regularizing Where Grammar (was Re: Add a while clause to for loops)
Erica Sadun
erica at ericasadun.com
Thu Jun 9 15:54:34 CDT 2016
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160609/66a63b18/attachment.html>
More information about the swift-evolution
mailing list