[swift-evolution] [Pitch] Retiring `where` from for-in loops
Ryan Lovelett
swift-dev at ryan.lovelett.me
Fri Jun 10 13:14:48 CDT 2016
@Xiaodi Wu a couple of times you've said things were "explicit"
this or that.
>* Swift is explicitly a C-family language. In most or all other C-
>family languages, for loop statements allow specification of
>conditions for exiting the loop but not for filtering. Therefore,
>Swift's use of `where` is unprecedented and needs to be learned anew
>by every user of Swift.
> That is worrying if true, because it suggests that it's enabling
> 'dialects' of Swift, an explicit anti-goal of the language
Though I've never read either of these before as being goals (or for
that matter anti-goals). Perhaps I'm looking in the wrong places though.
Can you please share these with me?
In trying to track that information down I read over
https://swift.org/about/Â trying to find if I could glean any information
about some guiding principles. When I stumbled upon this and wondered if
anyone else would find it illuminating.
>From the "Features" section:
>Fast and concise iteration over a range or collection
Does this proposal enhance that feature? Does this proposal weaken
that feature?
I've thought about that for a little bit and I'm pretty sure that
removing `where` from for in certainly does not enhance that feature
from my perspective.
If I understand everything this all started because `if` can no longer
have `where`. Â Following that and basing it completely on the example in
this proposal
(https://gist.github.com/erica/dd5935eca0d5d06b046184f41d56dd04#confusion-of-use)
it seems to me that the behavior of the `where` clause of the `while`
was analogous to the now removed `if` behavior.
Therefore, if we are going to remove something lets remove the `where`
clause from `while`. As is already correctly pointed out in the
"confusion of use" section the outlier behavior was `for in`. We
deprecated the `if` behavior because of [fill in the blank], forgive me
I never read the arguments, if `while` works the same way why does it
not logically follow that its `where` clause also be deprecated.
With that as far as I'm concerned this proposal is just requesting the
retirement of the `where` clause on the wrong loop structure. Of course
more examples could change my mind.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160610/077a67fc/attachment.html>
More information about the swift-evolution
mailing list