[swift-evolution] [Pitch] Retiring `where` from for-in loops

Xiaodi Wu xiaodi.wu at gmail.com
Tue Jun 14 11:32:20 CDT 2016


And from the WWDC Platforms SOTU: "Swift is super simple and
approachable.... It's great as a first language. And in fact, we think this
is so important that when we designed Swift this was an explicit design
goal."

I would be absolutely against adding any more sugar to the for loop. In
that sense, `where` sets a terrible example that certain features of
sequences deserve contextual sugar. (And before someone points it out
again, I've already argued why `for...in` holds its own weight, namely
difficulty of writing a correct `while` replacement and progressive
disclosure to the learner so that the concept of iterators can be learned
afterwards.)

In short, I would very much be opposed to adding keywords "for fun."

On Tue, Jun 14, 2016 at 11:18 AM Vladimir.S via swift-evolution <
swift-evolution at swift.org> wrote:

> FWIW I don't think we need all "4", just like we don't need `unless` as a
> pair to current `if` or `until` as a pair for current `while` loop.
>
> I.e. we have "continue" with current `where`, and you can use boolean
> inversion `!`. As for "break"(while) - my opinion the for-in loop will be
> more powerful and adds fun for coding (from wwdc keynote - "Swift is a
> powerful language.. writing Swift code is *fun*..." my opinion: using
> guard-continue or guard-break is *not* fun ).
>
> So in your words, it is better add *one* then remove *one*.
>
> The only question I'm not sure about if we should keep 'where' and 'while'
> keywords for these features, or rename them. For me it's OK to have 'where'
> and 'while' but probably I'll support another more clear keywords.
>
> On 14.06.2016 18:01, Erica Sadun via swift-evolution wrote:
> >
> >> On Jun 14, 2016, at 7:50 AM, plx via swift-evolution <
> swift-evolution at swift.org> wrote:
> >> For those particular keywords, I’d prefer having them (or equivalents).
> I’m not sure if I’d prefer having *all* of them—`where/unless` and
> `while/until`—or just one from each “pair”…I could go either way.
> >
> > In the proposal, my recommendations for including all 4 are:
> >
> > break: while / until
> > continue: if (formerly `where`) / unless
> >
> > As the thread has had sufficient redundancy, I'll refrain from making my
> case again for why I think it's better to remove the one than add the three.
> >
> > -- E
> >
> >
> > _______________________________________________
> > 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/20160614/dab2e61b/attachment.html>


More information about the swift-evolution mailing list