[swift-evolution] [Review] SE-0099: Restructuring Condition Clauses

Xiaodi Wu xiaodi.wu at gmail.com
Sun May 29 10:32:00 CDT 2016


I totally agree with Brandon that it makes sense in the context. But I
disagree with you: the behavior certainly isn't consistent. Those are two
orthogonal evaluations.

Personally, I've never been tripped up by the two different meanings of
where clauses and I've used both. Yet, when it was presented to me in prose
form in _Advanced Swift_ (a great read, btw), it was a shocking thing to
realize.

That these very experienced authors of the book felt compelled to point it
out to their audience, who are ostensibly all experienced users of the
language, suggests that there is something about the where clause not quite
intuitive for all people. So I consider it a net positive to eliminate the
inconsistency, whether or not it can be thought of as making sense.

On Sun, May 29, 2016 at 11:15 Thorsten Seitz <tseitz42 at icloud.com> wrote:

> Totally agree with Brandon. I don’t think that behavior is inconsistent.
>
> -Thorsten
>
>
> Am 28.05.2016 um 22:18 schrieb Brandon Knope via swift-evolution <
> swift-evolution at swift.org>:
>
> Doesn't this contextually make sense though?
>
> for, when read:
> "for each value in collection where some condition is met" do this loop
>
> while, when read:
> "while some condition where this constraint is met" do this loop
>
> It could just be because I know the behavior and am use to it, but I think
> it makes sense contextually when used.
>
> Brandon
>
> On May 28, 2016, at 4:06 PM, Xiaodi Wu via swift-evolution <
> swift-evolution at swift.org> wrote:
>
> I'm just gotta quote from Advanced Swift:
>
> Note that the where clause [in a for loop] does not work like the where
> clause in a while loop. In a while loop, iteration stops once the value is
> false, whereas in a for
> loop, it functions like filter.
>
> On Sat, May 28, 2016 at 16:00 Haravikk <swift-evolution at haravikk.me>
> wrote:
>
>>
>> > On 28 May 2016, at 20:21, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
>> >
>> > There's already an inconsistency in where clause behavior for `if` and
>> `while` versus `for` loops. It's nice IMO that the former uses are
>> eliminated in this proposal.
>>
>> Can you give an example? That sounds like something that should be
>> addressed separately rather than just dropping it.
>> Like I say I really like using it for basic bind + condition cases, so
>> I’m very much opposed to just tossing where clauses.
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
> _______________________________________________
> 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/20160529/43321276/attachment.html>


More information about the swift-evolution mailing list