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

Dany St-Amant dsa.mls at icloud.com
Thu Jun 9 21:45:50 CDT 2016


> Le 9 juin 2016 à 14:55, Xiaodi Wu via swift-evolution <swift-evolution at swift.org> a écrit :
> 
> There have been, in previous threads, several examples given where users of Swift have found the behavior of `where` to be misleading and confusing.

Sorry Xiaodi, but beside you (on multiple instances), and recently Erica, I have do not recall hearing that many voices saying that 'where' is confusing. Yes, there's was maybe even less voices stating that it is not confusing, but which group is more vocal?

Maybe I have been recently corrupt by Solid SQL queries:
select * from PEOPLE_TABLE where AGE_FIELD = 100

Or by my (likely) broken English:
The places where I had the most fun

But, to me, where can only suggest some filtering (thus tag to a for ..  in .., continue if not matching). 

I know there's a linguist on the list, maybe he could comment on whether or not using 'where' as a filter is proper or an abomination.

I do not think that because something is confusing to some, or at first, that it warrant removal from the language. The by-value/by-reference is well define, but can be confusing at first. Same goes for eager/lazy processing, or escaping vs non-escaping closure, or even the difference between closure and function. But no one suggest to remove them.

Dany

> In fact, the first of these proposals began with a question: how does one write arbitrary Boolean assertions after a let binding? The answer (use `where`) was found to be misleading and confusing.
> 
> I think you're being unfair to say that these proposals have no purpose other than an academic consistency.
>> On Thu, Jun 9, 2016 at 13:29 Jon Shier via swift-evolution <swift-evolution at swift.org> wrote:
>>         As time goes on, I’m feeling more and more that these consistency proposals are sorely misguided. Frankly, unless the syntax is confusing or misleading, even once the developer has learned the guiding principles of Swift, consistency is not a good argument for change. This proposal is the perfect example of this. No one will find the use of “where” in loops confusing, aside from those who will wonder why it was removed from if statements. There is no misleading behavior or confusing syntax here. This is just consistency for consistency’s sake. Once this proposal is done, then another will be made to remove “where” from another place in the language. Then another and another until it’s gone completely and a very useful part of the language is removed in the name of consistency. Which really just comes down to “where” isn’t used here, so it can’t be used there anymore. It’s death by a thousand cuts.
>> 
>> 
>> 
>> Jon Shier
>> 
>> 
>> > On Jun 9, 2016, at 1:16 PM, Erica Sadun via swift-evolution <swift-evolution at swift.org> wrote:
>> >
>> >
>> >> On Jun 9, 2016, at 11:11 AM, Charlie Monroe <charlie at charliemonroe.net> wrote:
>> >> See my latest post - included results with -Ofast. But still, using filter and lazy.filter is 10+% slower, which were the suggested alternatives to `where`.
>> >>
>> >>
>> >
>> > I need to correct this misapprehension.
>> > My suggested alternative to where was and remains `guard`.
>> >
>> > -- 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
> _______________________________________________
> 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/bd0ade50/attachment.html>


More information about the swift-evolution mailing list