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

Dany St-Amant dsa.mls at icloud.com
Wed Jun 15 16:58:08 CDT 2016


> Le 15 juin 2016 à 17:23, Jean-Daniel Dupas via swift-evolution <swift-evolution at swift.org> a écrit :
> 
> 
>> Le 13 juin 2016 à 17:26, Erica Sadun via swift-evolution <swift-evolution at swift.org> a écrit :
>> 
>> 
>>> On Jun 13, 2016, at 9:23 AM, let var go via swift-evolution <swift-evolution at swift.org> wrote:
>>> 
>>> I am 100% with Charlie on this. Expressiveness has to do with the *effectiveness* of conveying a thought or a feeling.
>>> 
>>> Keep "where". It is expressive. It conveys a specific idea effectively and concisely.
>> 
>> For those of you in favor of retaining `where`, how do you feel about adding `while`, `until`, `unless`, etc?
>> 
>> — E
> 
> What I like is the possibility to iterate over a filtered list using a ‘single’ statement, not the keyword itself. If you propose to replace where by something less confusing, or add other keywords, I’m all for it.
> 

For the folks who like the 'where' and do not like the 'guard .. else continue', (also considering in the equation the suggestion of renaming 'where' by 'if'). One can get the 'where' syntax without the 'where'  at the cost of one indentation level and the set of curly braces.

for element in dataArray {
  if condition {
    doWork()
  }
}

versus

for element in dataArray where condition {
  doWork()
}

Dany, slowly shifting into the "what's the point of keeping 'where'" camp


More information about the swift-evolution mailing list