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

Charlie Monroe charlie at charliemonroe.net
Mon Jun 13 11:02:44 CDT 2016


`while`, `until` and `unless` all implicate that the loop should break when the condition (or its negation) is met.

On the other hand, `where` as it is seems logical to me. Anyone who considers serious coding is likely to have basic knowledge of mathematics, so something such as

∀x ∈ X, x > 0

which translates into 

for x in X where x > 0

in Swift, which is pretty much how you'd read the mathematical statement. Yes, there is a comma, not `where` in the formula but when reading, you say "where" (unless you say "every x greater than zero").

> On Jun 13, 2016, at 5:26 PM, Erica Sadun <erica at ericasadun.com> wrote:
> 
> 
>> 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
> 



More information about the swift-evolution mailing list